sh - Shell script, how to process line by line for $@ -
i reading in inputs file in shell script:
sh script_name.sh < file.txt
i know $@ have content of file, want iterate through each line of file since file has new entries on every line.
i tried this:
for in $@ echo $i done but seems work.. note said echo $i in example, want other manipulation.
i having issues accessing elements in $line
below code
while read line in $line: echo $i done done i saved in test.sh file , feed in following test.txt file:
hello world time world food this got output:
hello world: time good: world food: as can see there ":" @ end of second string
while read line echo $line done regarding second requirement split each line on whitespace , process each field, need:
while read line in $line echo $i done done you must have been writing python ;-), because you've accidentally got trailing : in example.
you want:
for in $line instead of:
for in $line:
Comments
Post a Comment