查找文件名称为test的文件并输入文件存在的路径
/ 为绝对路径 .为相对路径
find / -name test -print
带测试的find命令
1 find . -newer test -print
在当前目录下查找比test 文件新的文件
联合查找,在当前目录下查找以下划线开头的文件或者是比test文件新的文件
1 find . ( -name "_" -or -newer test ) -type f -print
带命令的查找文件
1 find . newer test -type f -exec ls -l {} ;
在文件中查找字符串(在ls.txt文件中查找really)
1 grep really ls.txt
在两个文件中计算匹配行的数目
1 grep -c really ls.txt lsl.txt
在两个文件中计算不匹配行的数目
1 grep -c -v really ls.txt lsl.txt
here文档
1 #!/bin/sh 2 cat <<!A.xsk! 3 hello 4 my name is A.xsk 5 document 6 !A.xsk!
a_text_file
1 line is 1 2 line is 2 3 line is 3 4 line is 4
heret 调用a_text_file
1 #!/bin/sh 2 ed a_text_file << !A.xsk! 3 3 4 d 5 .,$s/is/was/ 6 w 7 q 8 !A.xsk! 9 10 exit 0
捕获exit信号,在脚本程序开始处添加下面这行代码
1 trap 'echo exiting:critical variable = $ critical_variable' EXIT