Read a text file in bash line by line with while. It will read till the end of line. You can modify the end of line setting a new value to EOF variable.
bash |copy code |?
1 while read line; do echo "${line}"; done < <(cat file.lst)
Read a text file in bash line by line with while. It will read till the end of line. You can modify the end of line setting a new value to EOF variable.
bash |copy code |?
1 while read line; do echo "${line}"; done < <(cat file.lst)
This is an example of how to create a bash menu using while and read.
bash |copy code |?
01 #!/bin/sh02 echo "Use one of the following options"03 echo " d : run date command"04 echo " > :" 05 echo " q: quit this menu"06 echo "enter your choice or type "q" to quit : \c"07 read option08 while [ "$option" != "q" ]09 do10 case $option in11 d ) date12 shift13 echo "enter your choice or type "q" to quit : \c"14 read option15 ;;16 > )17 shift18 echo "enter your choice or type "q" to quit : \c"19 read option20 ;;21 22 # ...23 24 25 26 27 shift28 echo "enter your choice or type "q" to quit : \c"29 read option30 ;;31 read option32 ;;33 q ) exit 034 ;;35 esac