此代码
my_file="/tmp/file_without_spaces"
if [ -f "${my_file}" ]; then
my_ls_aaaammgg_hhss="$(ls ${my_file} -l --time-style='+%Y%m%d_%H%M%S' | cut -d' ' -f6)"
mv "${my_file}" "${my_file}_${my_ls_aaaammgg_hhss}"
fi
例如变成。/tmp/file_without_spaces
/tmp/file_without_spaces_aaaammgg_hhss
/tmp/file_without_spaces_20250218_161244
例如,我怎样才能对名称中带有空格的文件执行相同的操作
/tmp/file with spaces
?
我想要得到/tmp/file with spaces_20250218_161244
。