我试图找出use Test::Version
cpan 中有哪些模块。所以我习惯minicpan
镜像它。我的问题是我需要遍历下载的档案,并 grep 档案中的文件。谁能告诉我我该怎么做?最好以一种方式告诉我存档中的哪个文件以及它在哪一行。
(注意:它们并非都是 tarball,有些是 zip 文件)
对于我的学校项目,我必须创建一个脚本,允许您搜索 zip 文件中打包的文件的内容。您可以在脚本中指定一个“搜索字符串”,后跟一个或多个 zip 文件,如下所示:
./searchZip.sh -s Tom ztest1.zip ztest2.zip
Found the word 'Tom' in the following files:
ztest1.zip : script1_q0638730_04-18-23-04-41.txt
ztest2.zip : script2_q0638730-04-25-19-52-07.txt
Run Code Online (Sandbox Code Playgroud)
我尝试了,但我不知道如何给出第二个参数,有人可以帮助我吗?谢谢你!这是我的代码:
function unzipFile()
{
unzip ztest1.zip -d zipFiles
unzip ztest2.zip -d zipFiles
unzip ztest3.zip -d zipFiles
}
if test -z "$1"
then
echo "Enter a name please "
exit
else
unzipFile
echo "Found the word '$1' in the following files:"
grep -ilR "$1" zipFiles/
fi
rm -r zipFiles/
Run Code Online (Sandbox Code Playgroud)