xargs,sed,grep,awk都是linux的高階命令.今天介紹xargs的應用.
先說明幾個常用選項:
-i 表示指定{}來接收參數
-t 表示在標準輸出上列印出命令.
-d 表示指定定界符.
-n 是指定命令接收的參數個數
- [root@localhost test]# ls
- a.tmp b.tmp
- [root@localhost test]# find . -name "*.tmp" |xargs -t rm
- rm ./b.tmp ./a.tmp
- [root@localhost ~]# echo -n abc a|xargs -i -d " " echo {}
- abc
- a
- [root@localhost ~]# echo -n abc a
- abc a[root@localhost ~]#
- [root@localhost test]# find . -name "*.tmp" |xargs -n1 -t rm
- rm ./b.tmp
- rm ./a.tmp
[火星人 ] linux 高階命令-xargs已經有469次圍觀