我想编写一个 shell 程序,它将遍历名称与这样的模式匹配的所有文件夹:
sudo sh shell.sh pub
Run Code Online (Sandbox Code Playgroud)
运行时,脚本将查找名称包含的所有文件夹pub并打印其修改日期。我希望有代码可以打印出如下图所示的结果:
我有这个代码,但它没有给我我期望的结果。
echo 'the folder '$1' was modified at ';
find -type d -name 'kam*' -exec stat -c '%y %n' '{}' \;
Run Code Online (Sandbox Code Playgroud)
我必须遍历每个文件夹并输出文本echo 'the file '$1' was modified at ';并打印图像中的日期。
我想要这样的结果:
netcom@hotspot:~$ bash script.sh testRegex Pub
the folder testRegex was modified on may 15 01:19
the folder Public was modified on may 19 01:19
the folder Pubos was modified on may 19 01:19
Run Code Online (Sandbox Code Playgroud)