bash – 如何去每个目录并执行命令?
发布时间:2020-12-15 16:37:42 所属栏目:安全 来源:网络整理
导读:如何编写一个bash脚本,通过parent_directory中的每个目录,并在每个目录中执行一个命令。 目录结构如下: parent_directory (name could be anything – doesnt follow a pattern) 001 (directory names follow this pattern) 0001.txt (filenames follow t
如何编写一个bash脚本,通过parent_directory中的每个目录,并在每个目录中执行一个命令。
目录结构如下:
您可以执行以下操作,当前当前目录为parent_directory:
for d in [0-9][0-9][0-9] do ( cd $d && your-command-here ) done (和)创建一个subshel??l,所以当前目录不会在主脚本中更改。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |