9

我正在创建一个sh脚本文件来将文件从一个文件夹移动到另一个文件夹,但只移动以system@.

那么我怎样才能只移动以 开头的文件system@呢?

#pseudo-code
foreach file "system@*.*" in dir
move to /.../...

提前致谢。

4

1 回答 1

17

在发布这样的问题之前,您应该真正查看 bash 参考。

for file in dir/system@*; do 
    mv "$file" /path/to/destination
done

显然我比我想象的还要累。3coins 的评论更精彩:

mv dir/system@* /path/to/destination

假设您没有足够的匹配文件超过最大命令行长度。

于 2012-10-03T02:15:55.810 回答