I want to search开发者_如何转开发 a word in lots of script files
It may linux software or script
Thanks
Do:
man grep
And read that. Then checkout man sed
and man awk
and have a peek at Perl. It is essential to know these things on Unix-like systems!
Next time, provide more info. with that said, you can try tools like grep, or awk with combination of find.
grep -r "word" *
Use a small shell script, which will print the number of occurrences of your search phrase in each file:
for file in `ls`;
do
printf '%-50s' "$file";
grep -c "SEARCH PHRASE HERE"
done
Which would give something like:
misc.rst 0
database_sources.rst 0
postgis_cookbook.rst 21
data_sources.rst 14
...
To find the occurrences of the phrase in each file, use cat
and grep
together:
cat -n filename | grep "SEARCH PHRASE HERE"
This would give you the lines in the file in which the phrase appears. The -n
argument gives you the lines with numbers, for easy finding.
精彩评论