LinuxQuestions.org
Visit Jeremy's Blog.
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 10-22-2008, 11:46 AM   #1
mcgao07
LQ Newbie
 
Registered: May 2008
Posts: 15

Rep: Reputation: 0
Question tail: cannot open `+5' for reading: No such file or directory


Hello,

I have a simple script that runs well on other linux but not on my new RHEL v5. It says:
"tail: cannot open `+5' for reading: No such file or directory"

The line causes the trouble is:
cat XYZ.poscar | tail +5 | awk '{printf("%4s%6s%4s\n",$5, $6, $4)}' > types_

I appreciate any help.

Michael
 
Old 10-22-2008, 11:54 AM   #2
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
What are you trying to do?

Forrest
 
Old 10-22-2008, 11:58 AM   #3
JD50
Member
 
Registered: Nov 2007
Location: Virginia
Distribution: Fedora, RHEL, CentOS
Posts: 67

Rep: Reputation: 17
It should be
Code:
 tail -5
not
Code:
 tail +5
 
Old 10-22-2008, 12:05 PM   #4
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
I'm guessing it should be:

Code:
tail -5 XYZ.poscar | awk '{printf("%4s%6s%4s\n",$5, $6, $4)}' > types_
But since I don't know what he's trying to do, I cant really say. Perhaps +5 is a valid option to tail on some flavour of Linux I've not used.

Forrest
 
Old 10-22-2008, 12:07 PM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
The tail +N syntax is obsolete and it's not accepted on some systems. Instead, you have to use the option -n explictly:
Code:
tail -n +5
or eventually you can specify an older POSIX standard in your environment. You can do this by defining the environment variable _POSIX2_VERSION, for example by using the env command:
Code:
env _POSIX2_VERSION=199209 tail +5 XYZ.poscar | awk ...
this force to run the tail command conformed to POSIX 1003.2-1992.
 
Old 10-22-2008, 12:10 PM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by forrestt View Post
Perhaps +5 is a valid option to tail on some flavour of Linux I've not used.
Yes. The +N option means "show the last lines of the file starting from the Nth line" instead of the default 10 lines.
 
Old 10-22-2008, 12:16 PM   #7
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
So, then it should be:

Code:
awk 'NR>4 {printf("%4s%6s%4s\n",$5, $6, $4)}' > types_
HTH

Forrest
 
Old 10-22-2008, 12:16 PM   #8
mcgao07
LQ Newbie
 
Registered: May 2008
Posts: 15

Original Poster
Rep: Reputation: 0
Thank you all for such prompt replies. The option "tail -n +5" really works.

Michael
 
  


Reply

Tags
rhel, tail



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] cdrecord: No such file or directory. Cannot open '/dev/pg0'. Cannot open SCSI driver. procfs Linux - Software 5 01-18-2008 10:06 AM
Verifying archive integrity...tail: cannot open `+6' for reading vamseekrishna Linux - Software 3 10-05-2007 05:41 AM
Tail Last Modified File in a Directory tyoungblood Linux - Software 3 08-12-2005 08:42 AM
awk: fatal:cannot open file for reading (no such file or Directory) in Linux sangati vishwanath Linux - Software 4 07-06-2005 12:59 AM
root-tail and xrootconsole: safe reading? iceman47 Linux - Security 1 12-04-2003 06:24 PM

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

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