我需要让脚本在第一次循环迭代中执行特定操作。
for file in /path/to/files/*; do
echo "${file}"
done
Run Code Online (Sandbox Code Playgroud)
我想要这个输出:
First run: file1
file2
file3
file4
...
Run Code Online (Sandbox Code Playgroud) 我需要反转 bash 脚本中的 for 循环。有一个目录,其中包含以 %Y%m.mp4 命名的视频(201701.mp4;201702.mp4、201703.mp4,...)。循环应从最旧的文件名开始(例如 201712.mp4) 如何反转我的 for 循环?
outputdir="/path/to/video/monthly/"
for file in "$outputdir"*.mp4
do
echo $file
done
Run Code Online (Sandbox Code Playgroud)