Linux程序设计-第二章-shell程序设计

重定向输出:

ls -l >lsoutput.txt

>>将输出内容附加到一个文件中

ps>>lsoutput.txt

重定向输入:

more<lsoutput.txt

 

管道:

ps | sort > pasort.out

ps| sort|more

ps -xo comm | sort | uniq | grep -v sh | more

cat mydata.txt | sort | uniq | >mydata.txt

 

shell 脚本:查找含有posix字符串的文件,first

#!/bin/sh
for file in *
do
if grep -q posix $file
then
echo $file
fi
done
exit 0

chmod +x first   first




posted @ 2011-12-23 17:27  时游  阅读(128)  评论(0编辑  收藏  举报