read file in shell script
Posted
by
moata_u
on Ask Ubuntu
See other posts from Ask Ubuntu
or by moata_u
Published on 2011-03-10T07:06:15Z
Indexed on
2011/03/10
8:18 UTC
Read the original article
Hit count: 176
command-line
|bash
how can i read file in shell script , then assign each line to an variable that i can use later ,,,(am thinking in way to load an default setting from file)
i already try :
process (){
}
FILE=''
read -p "Please enter name of default file : " FILE
if [ ! -f $FILE ]; then
echo "$FILE : does not exists "
exit 1
elif [ ! -r $FILE ]; then
echo "$FILE : can not read "
fi
exec 0<"$FILE"
n=0
while read -r line
do
(assign each line to an variable)
done
© Ask Ubuntu or respective owner