![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| read some lines from file!!! | andy2000 | Shell Programming and Scripting | 7 | 03-28-2007 05:55 AM |
| how to read lines one by one from a file | bihani4u | UNIX for Dummies Questions & Answers | 5 | 09-28-2006 08:55 PM |
| How to read lines from a flat file | bihani4u | Shell Programming and Scripting | 2 | 09-28-2006 02:54 PM |
| Read the lines from the file in batch | amitraorane | Shell Programming and Scripting | 2 | 01-26-2006 01:51 PM |
| How to read specific lines in a bulk file using C file Programming | rajan_ka1 | High Level Programming | 10 | 11-10-2005 03:29 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Read lines from file
i have a problem on my bourne shell script. I want to read line by line and then stop when the line does not have letters or is an empty string. But i encounter an error at "while [ read line -a $stop -eq 0 ]". The error nessage is "test.sh: test: unknown operator line". Can anyone help me on this thanks
Quote:
|
|
||||
|
Hi,
I have done the necessary changes for the code, pls check now, hope it should work now. also u have used $count > 4, but u have initialized $count to 1 instead of using > u can use <= it will work, if u use > then script will hang, pls change it accordingly n then run the script #!/bin/sh counter=1 stop=0 read line < /export/home/admin/test.sh while [ read line -a $stop -eq 0 ] do ### If reached 5th or greater row, means we have reached the rows ### as input if [ $counter -gt 4 -a $stop -eq 0 ] then executed=`echo $line | awk '{ print $1 }'` ### If reached 4th or greater row and it is blank, means we have reached ### the end of the daily reocrd elif [ $counter -gt 4 -a "'$line'" = "" ] then stop=1 echo "End of line" fi ### Increment row counter by 1 counter=`expr $counter + 1` done |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|