shell学习

$ for file in *
> do
> if grep -l POSIX $file
> then
> more $file
> fi
> done

查找当前目录下的文件是否包含POSIX字符串


grep (global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来)

-l,--files-with-matches


从文件中找出至少有三个字符的行
grep -i   '^...'   filename
如 grep -i  '^...' 1.c

-R-r--recursive
Read all files under each directory, recursively; this is equivalent to the  -d recurse option.
grep -r 字符串 filename
 grep -r dirp 1.c
从该文件中查找出含有字符串的行

if的结构为

if pipeline

then

...

elif pipeline

...

then

else

...

fi

你可能感兴趣的:(shell学习)