EOF of file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting EOF of file
# 1  
Old 08-14-2012
EOF of file

Hi,

I ve a file with name "check"
in this file "check" has two lines with contents
Quote:
2002::b08c:20ff:fe01:6004
2003::b08c:20ff:fe01:6005
now how to read these files line by line..

i used the code
Quote:
FILENAME=/check
cat $FILENAME | while read LINE
do
sh shelldom.sh $LINE
done
But these doesnt stop with two lines.. So how to set condition that only two lines be read and the program should stop its execution.. Please reply..
Thanks in advance..
# 2  
Old 08-14-2012
I used ksh for this, but any POSIX conforming shell should work:
Code:
#!/bin/ksh
FILENAME=/check
i=1
while [ $i -le 2 ] && read LINE
do
	sh shelldom.sh $LINE
	i=$(( i + 1 ))
done < $FILENAME

# 3  
Old 08-14-2012
try this.....

Code:
FILENAME=/check
head -2 $FILENAME | while read LINE
do
       sh shelldom.sh $LINE
done

# 4  
Old 08-14-2012
its STOPPING after two line.
There might be some other problem
# 5  
Old 08-14-2012
The program is probably reading from standard input and 'eating' all the lines your loop would have otherwise read.

You can prevent it from reading your lines by redirecting something else into it.

Also, you get a Useless Use of Cat Award.

Code:
while read LINE
do
        ./command </dev/null
done <inputfile

# 6  
Old 08-14-2012
Quote:
Originally Posted by raj_saini20
its STOPPING after two line.
There might be some other problem
If you read the requirements presented by Priya Amaresh in the 1st message in this thread, you'll see that she only wants to process the 1st two lines in the input file. The solutions pamu and I provided only feed the 1st two lines into the script as requested. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Match EOF on newline in a file

Hi, i have a file where the end-of-file might be at the end of of a valid text line or on a new line case a) p q r s t u <eof> case b) p q r s t u <eof> case c) p q r s t u <no data, only carriage return> <eof> I have a requirement where <eof> line should not be read if it's... (3 Replies)
Discussion started by: ysrini
3 Replies

2. Shell Programming and Scripting

EOF Usage - line 56: syntax error: unexpected end of file

Below is a test script I'm writing in the process of learning to write script. When I try to run it I get an unexpected end of file error on line 56. Thoughts? SCRIPT: #!/bin/bash # system_page - A script to produce a system information HTML file ##### Constants TITLE="My System... (1 Reply)
Discussion started by: mpercy725
1 Replies

3. UNIX for Advanced & Expert Users

Check EOF char in Unix. OR To check file has been received completely from a remote system

Advance Thanks. (1) I would like to know any unix/Linux command to check EOF char in a file. (2) Or Any way I can check a file has been reached completely at machine B from machine A. Note that machine A ftp/scp the file to machine B at unknown time. (5 Replies)
Discussion started by: alexalex1
5 Replies

4. Shell Programming and Scripting

remove last characters after %EOF (pdf binary file)

Hi, I want to know how I can remove the last characters of ANY pdf file. I read it under "od" in the command shell to see which were the last characters: $od corruptedfile.pdf -c When I see the file, I need to keep only the last characters, or "end of the file": %EOF (obviously keeping all... (1 Reply)
Discussion started by: diegugawa
1 Replies

5. Shell Programming and Scripting

eof in data file

Hi, How to detect eof character in a data file? I am reading a data file generated from UNIX. I use java scanner, the scanner's hasNextLine() returns false in the middle of the file. I suspect there is a eof in the middle of the data file. Does anybody know how to check if a file contains eof... (1 Reply)
Discussion started by: redwing
1 Replies

6. Shell Programming and Scripting

confused with << EOF EOF

Hi friends , I am confused with << EOF EOF Most of the cases I found sqlplus $db_conn_str << EOF some sql staments EOF another exapmle is #!/bin/sh echo -n 'what is the value? ' read value sed 's/XXX/'$value'/' <<EOF The value is XXX EOF (1 Reply)
Discussion started by: imipsita.rath
1 Replies

7. Shell Programming and Scripting

Until eof do????

Hey! Can I write a routine that allows me to in a txt file check line by line until the end of file? something like until do ---some code--- done maybe it is a stupid question but I never learned shell scripts and I need this :p thanks in advance (1 Reply)
Discussion started by: ruben.rodrigues
1 Replies

8. Shell Programming and Scripting

"unexpected end of file" when Iīm use EOF inside block if

I have a trouble in my script when i use EOF inside block if. If i use EOF whitout block if I donīt have problem. Guys any ideas? Sorry for my terrible English. #!/bin/sh set -xv HOST='ftp.fiction.com.br' USER='fictionuser' PASS='fictionpass' FILE='ftpteste.txt' busca=`find... (4 Replies)
Discussion started by: ricardo.ludwig
4 Replies

9. UNIX for Dummies Questions & Answers

\n after EOF

Hello all, I have unix file that ends with the following EOF '9999999999' I want to remove the '\n' character after EOF. What is the command that should be included in the script, before sending the file? will this work: $ echo "<99999999999>\c" >> <filename> thanks in advance. (3 Replies)
Discussion started by: priya12
3 Replies

10. Shell Programming and Scripting

How to check if the file DOES NOT have EOF

Hi, Please help me on this. how to check if the file DOES NOT have EOF ?? I am using ksh for this. (3 Replies)
Discussion started by: BasavarajaKC
3 Replies
Login or Register to Ask a Question