Shell to detect the end of file


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Shell to detect the end of file
# 1  
Old 09-12-2010
Shell to detect the end of file

Hi.

I'm not UNIX expert, I need to do a shell to read a sequential file and show in the console the record numbers read, until the end of file.

The reason of this shell is to be sure if the file is not corrupt.

Thanks
# 2  
Old 09-12-2010
Sounds like homework...
Code:
# count the lines
wc -l filename
# count and display the lines
nl filename
# just display the lines
cat filename
# count the bytes in the file
wc -c filename

To detect file corruption, use one of the utilities like cksum, md5, sha1, etc. That is what they are meant for.

Last edited by jim mcnamara; 09-12-2010 at 10:19 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Spooling File to My Desktop From Back-end using shell script

Hello all, I am trying to spool a SQL query output file from back-end to desktop in a certain path but it didn't work,the query writes the output in a file in the same directory at the back-end. note : i use the same query in sql developper and file was created in the desired path fine code... (1 Reply)
Discussion started by: bmaksoud
1 Replies

2. Shell Programming and Scripting

Tomcat failure detect via shell

Team, I am able to get ERROR message from my shell script, but sometime few severe error happen that tomcat server not started or not responding. How do we can detect it via shell script ? here is my snippet I used for my case tail -n0 -F $catalinaPath | while read line; do if echo... (0 Replies)
Discussion started by: Ghanshyam Ratho
0 Replies

3. Shell Programming and Scripting

Shell file if condition setting start and end dates

I have shell file that has the following logic, i am new to shell programming. What does process month $1 do? I am assuming that the below dates go back three months from sysdate month. is it right : curr_month=`date +%Y%m` Beg_o_time=`date -d "2012/03/01" +%Y%m` Process_months=$1... (1 Reply)
Discussion started by: cplusplus1
1 Replies

4. Shell Programming and Scripting

help needed with shell script to append to the end of a specific line in a file on multiple servers

Hi Folks, I was given a task to append three IP's at the end of a specific (and unique) line within a file on multiple servers. I was not able to do that with the help of a script. All I could was: for i in server1 server2 server3 server4 do ssh $i done I know 'sed' could be used to... (5 Replies)
Discussion started by: momin
5 Replies

5. Shell Programming and Scripting

sybase shell line 19: unexpected end of file

Hi, As i am new to this forum i dont really know where to place this doubt i am facing ,Please consider this In this code i am connecting two time to two different server / database and getting the .sql file where am i going wrong please guide..... me. thanks a lot if ; then echo... (2 Replies)
Discussion started by: oracle_coorgi
2 Replies

6. Solaris

Detect Invalid Data by C shell

Dear all, I'd be so grateful if I could get great feedback again for my problems. We usually spool some text files from our system in csv format. Unfortunately, some data contains ',' (comma) and it's rare case but when it comes to spool, that row included comma should be invalid data, due... (2 Replies)
Discussion started by: elph
2 Replies

7. Shell Programming and Scripting

Need UNIX shell scripting end to end information

Hi, I would like to learn shell scripting in UNIX. Can any one please give me the support and share the information/documents with me. If any documents please post it to aswanikumar_nimmagadda@yahoo.co.in Thanks in advance...!!! (3 Replies)
Discussion started by: aswani_n
3 Replies

8. Shell Programming and Scripting

Help on shell script : syntax error at line 62: `end of file' unexpected

Hi All, I have written a korn script (code pasted below). It is giving the error while debugging "new.sh: syntax error at line 62: `end of file' unexpected". I have re-written the whole code in VI and explored all help related to this error on this Unix forum and tried it. Somehow, I could... (7 Replies)
Discussion started by: schandrakar1
7 Replies

9. Shell Programming and Scripting

add a line at the end of a file using shell scripting

Hi All , I am new to shell scripting. i have a shell script(which is executed as a super user) , i want to it to do one more job for me. ie mounting a directory over other using lofs . i have done it manually using 1) using mount command mount -F lofs /export/home/dju /dju 2)... (4 Replies)
Discussion started by: meet123321
4 Replies

10. Shell Programming and Scripting

end of file problem with shell script

My shell script was working ok with K shell. But all of sudden, it started acting crazy. it keeps saying this: syntax error at line 70 : `"' unmatched I don't even have 70 lines in my file or this : syntax error at line 69: `end of file' unexpected Can this file got... (5 Replies)
Discussion started by: whatisthis
5 Replies
Login or Register to Ask a Question