Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\main::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/cms.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\main::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
linux怎样批量移动文件 - 互联网笔记

略微加速

略速 - 互联网笔记

linux怎样批量移动文件

2021-04-15 leiting (2744阅读)

标签 Linux

1.普通学生的解法,基本bash语法:

for i in 1 2 3; do mv $i/$i.jpg 4; done

2.优秀学生的解法,使用bash brace expansion:

set -B
for i in {1..3}; do mv "$i"/"$i.jpg" "4"; done

3.浸淫Linux多年学生的可能解法,熟悉常用命令和regex:

find -regex './\([A-Za-z0-9\-_ ]+\)/\(\1\).jpg' -exec mv {} 4 \;

4.工程上的解法,不管他叫jpg还是jpeg

IFS=$'\n'
for i in $(find . -type f); do xxd -l 5 -ps "$i" | fgrep ffd8fffe00 >/dev/null && mv "$i" 4; done

作者:罗林鑫
链接:https://www.zhihu.com/question/453298496/answer/1829717928
北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3