今天尝试写了第一个脚本程序,功能简单,仅仅是打印指定目录下,包含某些字符串的文件
#!/bin/bash
## “等号”两边不能有空格,否则会出错dir=/home/dir
##打印出此目录下,文件名包含abc的文件
for file_a in ${dir}/*; doecho $file_a|grep "abc"
if [ $? -eq 0 ] # if空格[空格$? -eq 0空格]
then echo ${file_a##*//}fi #结束符
done
今天尝试写了第一个脚本程序,功能简单,仅仅是打印指定目录下,包含某些字符串的文件
#!/bin/bash
## “等号”两边不能有空格,否则会出错dir=/home/dir
##打印出此目录下,文件名包含abc的文件
for file_a in ${dir}/*; doecho $file_a|grep "abc"
if [ $? -eq 0 ] # if空格[空格$? -eq 0空格]
then echo ${file_a##*//}