Error message with tail command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Error message with tail command
# 1  
Old 01-13-2012
Error message with tail command

Hello,

I wrote a script and part of the script, I have a validation to check if the file has <EOF> on the last line of the
file. If it does not have a <EOF>, then a message has to be written to a log file.

the code snippet shown below works fine, but it writes the below message if the <EOF> is not available.

PHP Code:
if [ `tail -1 $FILE` = "<EOF>" ]
then echo "<EOF> tag is available in the $FILE>>${errfile2>&1
else "<EOF> tag missing in $FILE>>${errfile2>&
./File_avail_cp.sh[82]: <EOF> tag missing in SALES_20111223: not found [No such file or directory]. I don't understand why I get message
- not found [No such file or directory].

If a file contains <EOF> then it works fine. error message is:
<EOF> tag is available in the ORDER_20111223

Can someone please help me resolve this?

thanks!
# 2  
Old 01-13-2012
Code:
if [ `tail -1 $FILE` = "<EOF>" ]
then echo "<EOF> tag is available in the $FILE" >>${errfile} 2>&1
else echo "<EOF> tag missing in $FILE" >>${errfile} 2>&1
fi

 
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 command help

Hi does anyone know how to create a file using the tail command? My book has this file I need to create and it says to use the tail command and that it is possible but I have no idea. Thanks. (4 Replies)
Discussion started by: drew211
4 Replies

3. Shell Programming and Scripting

Regarding Redirecting a command's default error message in script

Hi, I just need a small help. I have this simple script to check a huge list of IDs if they exist or not on a server. Before running I have tested it with only 5-6 IDs. Script works fine. But what I need it should not display the message of command's error message. That means if suppose an ID... (3 Replies)
Discussion started by: raj100
3 Replies

4. Shell Programming and Scripting

Help with tail command

Hi All, My query seems to be silly but Iam unable to find where the exact problem lies. I have a script to unzip set of files here is the script #!/bin/ksh Count=`cat /home/gaddamja/Tempfile | wc -l` while do Filename=`cat /home/gaddamja/Tempfile |tail -$Count | head -1` cd... (7 Replies)
Discussion started by: jagadish_gaddam
7 Replies

5. Shell Programming and Scripting

How to capture actual error message when a command fails to execute

I want to capture actual error message in case the commands I use in my shell script fails. For eg: ls -l abc.txt 2>>errorlog.txt In this case I understand the error message is written to the errorlog.txt and I assume its bacause the return code from the command ls -l abc might return 2 if... (3 Replies)
Discussion started by: prathima
3 Replies

6. Solaris

Tail command in one line

HI i have to copy the last 5000 lines form a log file and copy the same in the same file .overwriting the same log file. ex: tail -5000 testfile1 > testfile2 cat testfile2 mv tesftfile2 testfile1 will produce the correct result.but i want to have this done in one line???? (4 Replies)
Discussion started by: saurabh84g
4 Replies

7. Shell Programming and Scripting

Help regarding Error message: A test command parameter is not valid

Hi I am getting few messages when trying to run my script from the following lines in the script if test then // SomeCode fi The messages are as follows: testing.sh: OBLIGOR_GROUP_ID: 0403-012 A test command parameter is not valid. testing.sh:... (5 Replies)
Discussion started by: skyineyes
5 Replies

8. Shell Programming and Scripting

tail command..

I was wondering how can I do this I have file myfile.txt wc -l is: 5 000 000 I have to remove first 1 000 000 lines from header.. I tryed with tail -4000000 myfile.txt>newfile.txt but it does not work... any help?? (2 Replies)
Discussion started by: amon
2 Replies

9. Shell Programming and Scripting

tail command

Hi , I have found a interesting thing about tail command: when I tried to use 'tail -1 *' to look at every file with the current derectory, I only got one line of result of one file. But if I use 'head -1 *', I would get multiple lines. Is there a way to do get multiple lines with 'tail -1 *'... (3 Replies)
Discussion started by: whatisthis
3 Replies

10. UNIX for Advanced & Expert Users

help with !(tail -2) command.. using pipes

I am trying to using pipe (|) with ! (not) operator to list all the other files except the latest two and I am using the following command. $ ls -ltr *.lst|!(tail -2) ksh: 20050211180252.lst: cannot execute but it is trying to execute the file returned by tail -2. I am able to do that in 4... (8 Replies)
Discussion started by: sdlayeeq
8 Replies
Login or Register to Ask a Question