Rootop 服务器运维与web架构

xargs占位符

比如在log目录下有3个文件,文件名为a、b、c,现在需要改名,加上.bak。

[root@iZj6c5o8z3bqyepm9pw4xsZ log]# ll
总用量 0
-rw-r--r-- 1 root root 0 8月  23 09:46 a
-rw-r--r-- 1 root root 0 8月  23 09:46 b
-rw-r--r-- 1 root root 0 8月  23 09:46 c

通过-I参数指定一个占位符

[root@iZj6c5o8z3bqyepm9pw4xsZ log]# ls | xargs -I filename sh -c "mv filename filename.bak" 
[root@iZj6c5o8z3bqyepm9pw4xsZ log]# ll
总用量 0
-rw-r--r-- 1 root root 0 8月  23 09:46 a.bak
-rw-r--r-- 1 root root 0 8月  23 09:46 b.bak
-rw-r--r-- 1 root root 0 8月  23 09:46 c.bak

原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/5092.html

作者:Venus

服务器运维与性能优化

评论已关闭。