歡迎您光臨本站 註冊首頁

linux 高階命令-xargs

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0

xargs,sed,grep,awk都是linux的高階命令.今天介紹xargs的應用.

先說明幾個常用選項:

-i 表示指定{}來接收參數

-t 表示在標準輸出上列印出命令.

-d 表示指定定界符.

-n 是指定命令接收的參數個數

  1. [root@localhost test]# ls
  2. a.tmp b.tmp
  3. [root@localhost test]# find . -name "*.tmp" |xargs -t rm
  4. rm ./b.tmp ./a.tmp
  1. [root@localhost ~]# echo -n abc a|xargs -i -d " " echo {}
  2. abc
  3. a
  4. [root@localhost ~]# echo -n abc a
  5. abc a[root@localhost ~]#

  1. [root@localhost test]# find . -name "*.tmp" |xargs -n1 -t rm
  2. rm ./b.tmp
  3. rm ./a.tmp


[火星人 ] linux 高階命令-xargs已經有469次圍觀

http://coctec.com/docs/linux/show-post-47489.html