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

来源:互联网 发布:淘宝手机贷款 编辑:程序博客网 时间:2024/06/06 19:43
#!/bin/sh#the fisrt methodwhile read datado echo $datadone < test.info#the second methodcat test.info | while read linedo echo $linedone#the third methodfor line in `cat test.info`doecho $linedone
#将命令执行的结果赋值给变量的两种方法
#!/bin/sh#判断当前目录下文件名中包含e字符的var=$(ls | grep e);
echo $var
++++++++++++++++++++++++++++++++++++++++
#!/bin/sh
var=`ls | grep e`
echo $var