- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- ksh script Q about removing entries from a list in...
Operating System - Linux
1752562
Members
4649
Online
108788
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-30-2008 07:57 AM
тАО01-30-2008 07:57 AM
Re: ksh script Q about removing entries from a list in a VAR
I find Sandman! post really attractive as it gives the answer with the reverse order that Steve wanted ;-)
Of course NO POINT
Eric
Of course NO POINT
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-30-2008 08:59 AM
тАО01-30-2008 08:59 AM
Re: ksh script Q about removing entries from a list in a VAR
Ok let me summarize.....
one way: ls -1tr | sed '$d' | sed '$d'
I don't like that I pipe to sed twice.
one way: ls -1t | tail -n +3
The +3 means to tail line 3 and up. (tail -n -3 would be the last 3 lines).
If the number of lines in the ls command is a very large number, the tail would fail. But this will be a small number of files.
one way: ls -1tr | awk '{x[NR]=$0} END {for(i=1;i This awk script is nice. But I wouldn't use it until I knew people looking at it would understand it. And I would hope it worked on all versions of awk.
For me, I like the tail idea the best. But I REALLY like the fact that there is more than one way to do it.
Thank you all.
one way: ls -1tr | sed '$d' | sed '$d'
I don't like that I pipe to sed twice.
one way: ls -1t | tail -n +3
The +3 means to tail line 3 and up. (tail -n -3 would be the last 3 lines).
If the number of lines in the ls command is a very large number, the tail would fail. But this will be a small number of files.
one way: ls -1tr | awk '{x[NR]=$0} END {for(i=1;i
For me, I like the tail idea the best. But I REALLY like the fact that there is more than one way to do it.
Thank you all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-30-2008 09:11 AM
тАО01-30-2008 09:11 AM
Re: ksh script Q about removing entries from a list in a VAR
You said "But I wouldn't use it until I knew people looking at it would understand it. ". So I make the post for Sandman! as he can't control himself !
{x[NR]=$0}
==> For each line initialize an array (x) with the line itself ($0). NR is the current line number
END {for(i=1;i
==> at end of input stream, that is ls -1tr, just print all lines but the two last
It will work ... assuming that number of files listed is not greater that the limit of awk on array sizes.
No needs to give POINT
Regards
Eric
{x[NR]=$0}
==> For each line initialize an array (x) with the line itself ($0). NR is the current line number
END {for(i=1;i
==> at end of input stream, that is ls -1tr, just print all lines but the two last
It will work ... assuming that number of files listed is not greater that the limit of awk on array sizes.
No needs to give POINT
Regards
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-30-2008 09:20 AM
тАО01-30-2008 09:20 AM
Re: ksh script Q about removing entries from a list in a VAR
hi Steve:
So, if 'tail', sed' and 'awk' are OK for the filters, why not Perl?
# ls -1tr|perl -nle 'push @a,$_;END{print "@a[2..$#a]"}'
After all, TMTOWTDI.
Regards!
...JRF..
So, if 'tail', sed' and 'awk' are OK for the filters, why not Perl?
# ls -1tr|perl -nle 'push @a,$_;END{print "@a[2..$#a]"}'
After all, TMTOWTDI.
Regards!
...JRF..
- Tags:
- Perl
- « Previous
-
- 1
- 2
- Next »
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP