通过shell脚本实现从文件中读取数据的几种方法

#!/bin/sh

#the fisrt method
while read data
do 
	echo $data
done < test.info

#the second method

cat test.info | while read line
do 
	echo $line
done

#the third method
for line in `cat test.info`
do
	echo $line
done



#将命令执行的结果赋值给变量的两种方法
#!/bin/sh

#判断当前目录下文件名中包含e字符的
var=$(ls | grep e);
echo $var
++++++++++++++++++++++++++++++++++++++++
#!/bin/sh
var=`ls | grep e`
echo $var

你可能感兴趣的:(shell)