Read from file in shell script
The shell script(readfile.sh) to read line by line from the file (input.txt):
#!/bin/sh while read line do inputargs=($line) echo "Reading..." echo "arg1: ${inputargs[0]}" echo "arg2: ${inputargs[1]}" done < "input.txt"
The input.txt file
one apple two oranges three bananas
To run the script readfile.sh
chmod +x readfile.sh ./readfile.sh
The output from running the readfile.sh
Reading... arg1: one arg2: apple Reading... arg1: two arg2: oranges Reading... arg1: three arg2: bananas
Search within Codexpedia
Custom Search
Search the entire web
Custom Search
Related Posts