LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how do i list just the first and last of a listing? (https://www.linuxquestions.org/questions/linux-general-1/how-do-i-list-just-the-first-and-last-of-a-listing-489061/)

beeblequix 10-03-2006 11:44 AM

how do i list just the first and last of a listing?
 
I have a series of files of this pattern:
name.log.nnn.gz.

I'd like to list just the first and last one, and being that linux is so robust I wonder how many different or better ways to do this there are.

This works:
ls -g name.log.001.gz name.log.999.gz

but it would be nice to use 'head' 'tail' 'gawk' etc. Ideas?

marozsas 10-03-2006 12:31 PM

Quote:

Originally Posted by beeblequix
This works:
ls -g name.log.001.gz name.log.999.gz

I am not sure if I understand what you want, because you already knows how to do using head/tail:

Code:

$ ls -g | head -1; ls -g | tail -1
or better (only one listing of the directory)

Code:

$ ls -g > /tmp/listing.$$
$ head -1 /tmp/listing.$$
$ tail -1 /tmp/listing.$$


beeblequix 10-03-2006 12:48 PM

no no, i was looking for exactly that -- ";". Silly simple things...
Thanks a bunch :)


All times are GMT -5. The time now is 09:54 AM.