帮我写个很简单的shell脚本,写的好可以加分

来源:百度知道 编辑:UC知道 时间:2024/05/18 16:45:43
内容和要求:
Please come out a shell script to count number of all lines which include word 'words'(whole word match, but not case sensitive) in all files which file name is begin with 'a' and end with '.txt' under a directory and all of its directories.
英文很简单,不用翻译了吧?每行最好边上用汉语进行解释。
谢谢大家了,运行成功后可以我会加分。
仔细看这个英文的确是说的不怎么样。
大致意思:编写个UNIT下的SHELL脚本,在所有路径下,对所有文件中(是指文件里面的内容,不是文件名)包含words这个单词的,并文件名(现在是文件名了)以a打头的TXT文本文件进行计数。(大小写无关)

关于这个,下面的部分能帮我详细写一下吗?
假设我所有的要搜索的文件和文件夹都在d:/Rubbish/目录下,scripts在d:/Scripts目录下

你翻译一下吧~
如果能写的话,我可以帮你写一下,是unix 下的shell,需要帮忙可HI我

你可以用 find . -name "a*.txt" -print > astart.log
在你的根目录下 cd / 查找所有a打头的TXT文本

然后用 awk 或其它方法截取astart.log里的文本路径进行循环,查找(grep)
含有words的文件

思路基本上是这样.

let cnt=1;
for i in `cat astart.log`
do

echo "第"$cnt"次:"$i
let cnt=$cnt+1;
done

这样就可循环出路径了,请写在shell文本里再附执行权限执行