LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 04-07-2004, 04:57 AM   #1
Beppe83
Member
 
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?

Thanx!
 
Old 04-07-2004, 06:00 AM   #2
Gnuru
Member
 
Registered: Jan 2004
Posts: 53

Rep: Reputation: 15
Try this:

Code:
ls -l | tac | tail -n 5
 
Old 04-07-2004, 06:05 AM   #3
hw-tph
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 )


Håkan
 
Old 04-07-2004, 08:11 AM   #4
Beppe83
Member
 
Registered: Mar 2004
Posts: 41

Original Poster
Rep: Reputation: 15
Thank you!
 
  


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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:38 PM.

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