LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-03-2006, 11:44 AM   #1
beeblequix
Member
 
Registered: Oct 2005
Location: Tierra Firma, Earth
Distribution: Debian of course...
Posts: 198

Rep: Reputation: 30
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?
 
Old 10-03-2006, 12:31 PM   #2
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
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.$$

Last edited by marozsas; 10-03-2006 at 12:36 PM.
 
Old 10-03-2006, 12:48 PM   #3
beeblequix
Member
 
Registered: Oct 2005
Location: Tierra Firma, Earth
Distribution: Debian of course...
Posts: 198

Original Poster
Rep: Reputation: 30
no no, i was looking for exactly that -- ";". Silly simple things...
Thanks a bunch
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
list contents of directory without listing contents baddah Linux - Newbie 2 06-12-2006 04:02 AM
Apache Directory Listing Of NFS Mount, cannot view directory list via apache luqmana Linux - Networking 2 12-19-2005 06:03 AM
get list of latest list of packages bobwall Linux - Distributions 1 11-30-2004 03:48 PM
wireless channel list different from router's list heluani Linux - Laptop and Netbook 1 08-29-2004 10:04 PM
is there a list somewhere listing (or even explaining) mandrake tools? pdmackenzie Mandriva 2 09-12-2003 07:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration