小编Dig*_*uma的帖子

shell打印所有目录名称匹配模式的修改日期

我想编写一个 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)

command-line bash 14.04

4
推荐指数
2
解决办法
703
查看次数

标签 统计

14.04 ×1

bash ×1

command-line ×1