LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-21-2011, 02:50 AM   #1
type8code0
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Rep: Reputation: 0
"tail -n 1 filename" error while "head -n 1 filename" is ok?


Hi all,

I was wondering why tail –n 2 filename produce an error when I manage to do similar command on head –n 2 filename successfully

Code:
SunOS{type8code0}: tail -n 2 filename
  usage: tail [+/-[n][lbc][f]] [file]
         tail [+/-[n][l][r|f]] [file]
 
Old 03-21-2011, 05:05 AM   #2
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 101Reputation: 101
Try `tail -2 filename`.
 
1 members found this post helpful.
Old 03-21-2011, 05:09 AM   #3
rgdacosta
Member
 
Registered: Jun 2007
Location: South Africa
Distribution: Linux Mint,Fedora, openSUSE, RHEL, SLES, Scientific Linux
Posts: 71

Rep: Reputation: 25
tail -n 5 /etc/passwd works on both my Fedora and openSuSE systems.

so does tail -5 /etc/passwd
 
1 members found this post helpful.
Old 03-21-2011, 06:10 AM   #4
type8code0
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Original Poster
Rep: Reputation: 0
Cool

Thanks quanta & rgdacosta. It works! Many thanks to both of you

Code:
SunOS{type8code0}: cat file
line 1
line 2
line 3
line 4
line 5
Code:
SunOS{type8code0}: head -2 file
line 1
line 2
Code:
SunOS{type8code0}: tail -2 file
line 4
line 5
Code:
SunOS{type8code0}: head -n 2 file
line 1
line 2
Code:
SunOS{type8code0}: tail -n 2 file
usage: tail [+/-[n][lbc][f]] [file]
       tail [+/-[n][l][r|f]] [file]
 
  


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
[SOLVED] move all ".txt" files, adding parent directory to filename mostofmonty Linux - Newbie 9 09-15-2009 08:39 AM
more efficient {min,max} than "sort | {head,tail} -1"? magicbronson Linux - Software 17 07-04-2009 12:26 PM
Cannot access "man pages" as normal user - temp filename creation error. uncle-c Linux - Newbie 2 03-11-2008 01:10 PM
How to make newer "tail" behave like older "tail" rylan76 Linux - Software 4 12-07-2007 04:27 AM
DPKG & "files list file for package `pkg-config' contains empty filename" error :( Angelus Debian 2 04-02-2005 07:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:02 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