seaaide 发表于 2003-5-12 20:09:58

求教一查找命令,谢了先

redhat8.0下有没有什么命令可以在一目录中的所有文件中,查找一关键字

比如说我要在目录/home/src下的所有文件中查找seaaide,并替换成seaside该用什么命令?

谢了先:)

iven@linux 发表于 2003-5-12 20:22:31

用grep可以查找字符串
但要换就不得而知了

powerme 发表于 2003-6-15 01:34:40

我只能负责帮你查找seaaide,替换你教教我!!

cat a
dir /home/src/* | (while read file;
do
cat $file | grep seaaide
done
)
bash<a

powerme 发表于 2003-6-17 00:16:35

cat a
touch /home/fileA&&dir /home/src/* | (while read file;
do
cat $file | sed 's/seaaide/seaside/g'>/home/fileA&&cat /home/fileA>$file
done
rm -f /home/fileA

chg1226 发表于 2003-6-17 17:29:14

单独命令应该不行,写脚本吧,楼上的powerme已经给出了主要部分cat $file | sed 's/seaaide/seaside/g'>/home/fileA&&cat /home/fileA>$file
页: [1]
查看完整版本: 求教一查找命令,谢了先