Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从unix shell在多个目录中发出bash命令_Unix - Fatal编程技术网

从unix shell在多个目录中发出bash命令

从unix shell在多个目录中发出bash命令,unix,Unix,我需要执行一个简短的脚本,只是重命名几个文件(mv) 脚本位于大约50个文件夹中,每个文件夹都有名称,目前我正在shell中执行它们,并使用以下命令移动到下一个文件夹: bash rename && cd ../folder01 然后按向上并更改最后一个数字 是否有办法在一行中的所有文件夹中执行脚本?当然,请使用for循环: for f in folder*; do (cd "$f" && bash rename) ; done 当然,使用for循环: for

我需要执行一个简短的脚本,只是重命名几个文件(mv)

脚本位于大约50个文件夹中,每个文件夹都有名称,目前我正在shell中执行它们,并使用以下命令移动到下一个文件夹:

bash rename && cd ../folder01
然后按向上并更改最后一个数字

是否有办法在一行中的所有文件夹中执行脚本?

当然,请使用for循环:

for f in folder*; do (cd "$f" && bash rename) ; done
当然,使用for循环:

for f in folder*; do (cd "$f" && bash rename) ; done

你也不需要每次都复制你的脚本folder@arashkordi我是用“echo folder{10..49}| xargs-n1 cp script”复制它的,你也不需要每次都复制你的脚本folder@arashkordi我使用“echo folder{10..49}| xargs-n1cp脚本”复制它