Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 04-07-2004, 05:57 AM   #1
Registered: Mar 2004
Posts: 41

Rep: Reputation: 15
Help with 'tail' command!

Hi all.

I'm writing a simple bash script, and I need help with the 'tail' command; ok first of all I execute the 'ls' command and I pipe it to the 'tail' one with this option '-n N' where N is the number of lines I want to display.

Now the point is the I need the FIRST N lines and not the LAST ones; I read in the 'man' of tail that if I use '+' before the number of lines I want to see. It doesn't work. Here it is:

ls -l | tail -n +5

Ok, this is not running. Anyone can help?

Old 04-07-2004, 07:00 AM   #2
Registered: Jan 2004
Posts: 53

Rep: Reputation: 15
Try this:

ls -l | tac | tail -n 5
Old 04-07-2004, 07:05 AM   #3
Senior Member
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
Or just use head instead of tail (sounds like the beginning of a bad joke but it isn't )

Old 04-07-2004, 09:11 AM   #4
Registered: Mar 2004
Posts: 41

Original Poster
Rep: Reputation: 15
Thank you!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
root tail scylla Linux - Software 9 08-03-2005 05:44 PM
How to see that is the HDD doing EXACTLY like tail johnnydangerous Linux - Software 2 03-17-2005 03:52 PM
Coloured tail??? bram2000 Linux - Software 1 01-28-2005 12:42 PM
Howto end the "tail" command??? Schmurff Linux - Newbie 5 03-03-2004 06:32 AM
tail -f dcoder Programming 8 09-01-2003 09:41 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:48 PM.

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