shell脚本实现读取文件中的字符串,并把该行字符串赋值给变量,文本中每行的字符串可能包含空格。

麻烦大神给出解决办法,谢谢了!!
例如:
How are you ?
ok?
读取后
第一次:string=How are you?
第二次:string=ok?

$bash 1.sh
string=how are you?
string=ok?

$cat 1.sh
#!/usr/bin/bash
while read string
do
    echo "string=$string"
done < 111

 $cat 111
how are you?
ok?

脚本名1.sh,  要读取的文件名111。

追问

比较高大上的解法
cat file | while read line
do
echo -e $line
done

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-03-18
这个是小意思了。shell编程大神!发下私信啊
第2个回答  2014-03-18
发发发大为的哇
相似回答