linux shell

来源:互联网 发布:linux下源码安装mysql 编辑:程序博客网 时间:2024/06/06 17:37
#!/bin/shfor line in $(cat all_files.txt)doif [ -f "$line" ];  #A folder like /tmp/a/b is also true for -e, there is a whitespace before and after "-f".thensed 's/abc/def/g' $line >> ${line%.*}.$(date +%Y_%M_%d).fix  #elseecho "$line" >> files_not_found.txtfidone
shell读取文件的一个更加高效的方法,有两个优势:1.不用创建管道;2.不用开启cat进程。
<pre name="code" class="java">while read -r linedo        echo $linedone < all_files.txt
                                             
0 0