![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help to process each line in a file... | shyjuezy | UNIX for Dummies Questions & Answers | 7 | 05-14-2008 04:20 AM |
| Need to serach if a new line character exists on the last line in a file | sunilbm78 | UNIX for Dummies Questions & Answers | 10 | 02-29-2008 11:15 AM |
| Multiple file processing - 1st line only to process - search/match substring | toneatlondon | Shell Programming and Scripting | 2 | 01-02-2008 06:20 PM |
| Appending the line number and a seperator to each line of a file ? | pjcwhite | Shell Programming and Scripting | 4 | 03-20-2007 10:29 PM |
| Remove header(first line) and trailer(last line) in ANY given file | madhunk | Shell Programming and Scripting | 2 | 03-13-2006 12:36 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Process file line by line
Hi
I have a csv file as follows 608, Barnwood PFS,,2 150, Barnwood CS,2,4 etc When i do for lines in `cat file.dat` the space in second argument seems to screwing the lines up. Any suggestions to get around this? Thanks |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
The slow for-loop and the useless use of cat can all be avoided with....
Code:
while read line; do
# do whatever you want to ${line} - let's just echo it
echo "${line}"
done < inputfile.csv
ZB |
|
#3
|
|||
|
|||
|
Hi ,
i encountered the following problem doing that : while read line do serveur1=`echo $line|awk 'BEGIN {FS="\/"} {print $1}'` serveur2=`echo $line|awk 'BEGIN {FS="\/"} {print $1}'|sed -e s/A/B/g` chemin1=`echo $line|awk 'BEGIN {FS="\ "} {print "/base/base01/"$2}'` chemin2=`echo $line|awk 'BEGIN {FS="\ "} {print "/base/base01/"$2}'|sed -e s/base01/base02/g` rsh $serveur1 -l notes01 "mv $chemin1 $chemin1.leon" done < $fic_tmp1 the while treatment doesn't treat correctly the input file and exit after the first line. It seems that the differents variables in the rsh command don't return correctly the hand to the while treatment ! How to correct that ? Thanks in advance Christian |
|
#4
|
|||
|
|||
|
You have to use field separator as ",". what you are going to from
608, Barnwood PFS,,2 150, Barnwood CS,2,4 please elaborate to help you out. hth. |
|
#5
|
|||
|
|||
|
If i suppress the "rsh" statement and simply do "echo $line" , the loop is working correctly so what's the matter with rsh command ?
Christian |
|
#6
|
|||
|
|||
|
Perderabo said :
"Your rsh should have a -n option. Use it." ans it works ! Thanks all Chris |
|||
| Google The UNIX and Linux Forums |