tail issue!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting tail issue!
# 1  
Old 09-08-2010
inconsistent tail command on different linux versions!

Hi,

I had few scripts which were running fine on linux:
Code:
uname -a
Linux ######### 2.6.9-89.ELsmp #1 SMP Mon Apr 20 10:33:05 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

from some front end application. Recently there was a migration of this application on some other linux m/c:
Code:
 
uname -a
Linux #########  2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

after which scripts having code lines as follows fails!!

Code:
 
cat <file name> | tail +2
tail: cannot open `+2' for reading: No such file or directory

I don't know why this is happening. Can anybody please suggest?

-dips

Last edited by dips_ag; 09-08-2010 at 09:27 AM.. Reason: changed the title
# 2  
Old 09-08-2010
cat <file name> | tail -2
# 3  
Old 09-08-2010
tail with + option is not available on every linux/unix,


use
Code:
sed 1d

instead
# 4  
Old 09-08-2010
Per POSIX:
The plus sign is obsolescent and was supported only for wide character applications.

You have a newer kernel, along with a newer version of GNU coreutils, it is interpreting the +2 as a file name since it thinks that options only begin with the "-" character.

Try:
Code:
tail -n +2

This User Gave Thanks to jim mcnamara For This Post:
# 5  
Old 09-08-2010
Jim,
Thanks for explanation.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Tail -f Command help

Hi Team, Can anyone help me here: I have to access server logs via putty and these logs file is a trailing file (continously updating) with ERROR and WARNINGS... I need to know if I can pull this trailing file to a local drive so that I can do some higlighting on some keywords through Notepad... (13 Replies)
Discussion started by: jitensetia
13 Replies

2. Shell Programming and Scripting

Tail +

because the tail +2 on the first line gives me the file name pomga I do not want anything like what I miss tail +2 ejemplo.txt ouput ==> ejemplo.txt <== 1 2 3 4 5 6 7 8 9 10 (2 Replies)
Discussion started by: tricampeon81
2 Replies

3. UNIX for Dummies Questions & Answers

[Solved] Tail command issue in Linux

Hello, When I am trying to use tail +13 filename.csv it is throwing an error. tail: cannot open `+13' for reading: No such file or directory and then prints last 10 lines of the file. (File is present on the path) But when i try tail -13 filename.csv it runs perfectly. Could I have... (5 Replies)
Discussion started by: AnkitSenghani
5 Replies

4. Shell Programming and Scripting

Joining multiple files tail on tail

I have 250 files that have 16 columns each - all numbered as follows stat.1000, stat.1001, stat.1002, stat.1003....stat.1250. I would like to join all 250 of them together tail by tail as follows. For example stat.1000 a b c d e f stat.1001 g h i j k l So that my output... (2 Replies)
Discussion started by: kayak
2 Replies

5. Shell Programming and Scripting

AWK / tail Issue

Hello, I am using a tail command to fetch the line before last in a log file. the two last lines are as followed: 11-01-16 11:55:45.174 | CClientObject::InitTraceLevelInCache Starting CClientObject::InitTraceLevelInCache End I am doing a awk statement to gather only the numeric... (1 Reply)
Discussion started by: LiorAmitai
1 Replies

6. Shell Programming and Scripting

Issue Filtering Tail

Hi Folks, I have a log that contains data as shown below: 11:59:43,144 (1,850) Signal : .... 11:59:44,109 (1850) Bps : ..... I wish to remove "" from all lines and it is on the start of every line. I have achieved that successfully using the command: tail -f imp.log | sed 's/\... (4 Replies)
Discussion started by: umairrahman
4 Replies

7. Shell Programming and Scripting

tail | grep

The program that is running on my machine generates log files. I want to be able to know the number of lines that contain "FT" in the most recent log file. I wrote the following, but it always returns zero. And I know the count is not zero. Any ideas? ls -rt *.log | tail -n 1 | grep -c FT (6 Replies)
Discussion started by: sdilucca
6 Replies

8. Shell Programming and Scripting

tail -f

I am trying to extract a particular line from a.log which keeps appending every sec and output that into a newfile b.log which should append itself with filtered data received from a.log I tried tail -f a.log |grep fail| tee -a b.log nothing in b.log tail -f a.log |grep fail >>b.log ... (4 Replies)
Discussion started by: wannalearn
4 Replies

9. Shell Programming and Scripting

Tail??

Hello all, I have search the forum and could not find an answer...Here is what I am trying to do. Every 15 minutes, a script send uptime output to a logfile (dailylog.log), that file contains lines like the one below: 11:21am up 44 days, 19:15, 1 user, load average: 0.00, 0.02, 0.03 ... (7 Replies)
Discussion started by: qfwfq
7 Replies

10. Shell Programming and Scripting

using tail -f

Working in HP-UX 10.20. I eventually want to write a bourne shell script to handle the following problem, but for now I am just toying with it at the command line. Here's what I am basically trying to do: tail -f log_X | grep n > log_Y I am doing a tail -f on log_X . Once it sees "n", I... (6 Replies)
Discussion started by: cdunavent
6 Replies
Login or Register to Ask a Question