foreach i (`grep "字串" * | awk 'BEGIN {FS=":"} {print $1}'`)
mv $i ${i}.bak
rm ${i}.bak
end
rm ${i}.bak > /dev/null 2>&1作者: pxlsszf 时间: 2004-06-01 18:25 标题: 在目录及子目录中的文件中查询某个字符串 use this shell:
find . -type f -exec grep "find_string" {} \; -print作者: zhangweibo 时间: 2006-12-31 09:02
原帖由 pxlsszf 于 2004-6-1 18:25 发表
use this shell:
find . -type f -exec grep "find_string" {} \; -print
linux的命令真是强大,这个比较实用,谢谢!作者: szszszsz 时间: 2006-12-31 14:41
如果是文件里面的内容话,应该可以用grep "字符串" -r 要目录,-r是递归下去的作者: wudicc 时间: 2006-12-31 15:58
试过了,确实好用!作者: IAMTOP1982 时间: 2006-12-31 16:00
grep -r 应该也可以作者: seasee 时间: 2006-12-31 20:13
-d ACTION, --directories=ACTION
If an input file is a directory, use ACTION to process it. By
default, ACTION is read, which means that directories are read
just as if they were ordinary files. If ACTION is skip, direc-
tories are silently skipped. If ACTION is recurse, grep reads
all files under each directory, recursively; this is equivalent
to the -r option.
-R, -r, --recursive
Read all files under each directory, recursively; this is equiv-
alent to the -d recurse option.
--include=PATTERN
Recurse in directories only searching file matching PATTERN.