日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

find -exec 与xargs 区别

發布時間:2025/3/21 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 find -exec 与xargs 区别 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

find . -name "*.txt" -exec rm {} \;
find . -name "*.txt" | xargs rm {}?


-exec
? ? 1.參數是一個一個傳遞的,傳遞一個參數執行一次rm
? ? 2.文件名有空格等特殊字符也能處理
-xargs?
? ? 1.一次將參數傳給命令,可以使用-n控制參數個數
? ? 2.處理特殊文件名需要采用如下方式:
? ? find . -name "*.txt" print0 |xargs -0 rm {}?

實驗結果如下,可以清楚看到參數傳遞過程

[cpp] view plain copy
  • [root@andes.com?~/tmp/dir]#find?.?-type?f?|xargs?-t?-n?2?echo??
  • echo?./data.txt?./env2.txt???
  • ./data.txt?./env2.txt??
  • echo?./env.txt?./export2.txt???
  • ./env.txt?./export2.txt??
  • echo?./s.txt?./d.txt???
  • ./s.txt?./d.txt??
  • echo?./export.txt?./set.txt???
  • ./export.txt?./set.txt??
  • echo?./fuck.txt???
  • ./fuck.txt??
  • [root@andes.com?~/tmp/dir]#find?.?-type?f?-exec?echo?begin?{}?\;??
  • begin?./data.txt??
  • begin?./env2.txt??
  • begin?./env.txt??
  • begin?./export2.txt??
  • begin?./s.txt??
  • begin?./d.txt??
  • begin?./export.txt??
  • begin?./set.txt??
  • begin?./fuck.txt??
  • [root@andes.com?~/tmp/dir]#??

  • 技巧: find -print0 ?與 xargs -0 的結合避免文件名有特殊字符如空格,引號等無法處理:

    ?find . -name "*.txt" print0 |xargs -0 rm {}?

    find?

    ? ? ? ?-print True; print the full file name on the standard output, followed by a newline. ? If you are piping the
    ? ? ? ? ? ? ? output of find into another program and there is the faintest possibility that the ?files ?which ?you
    ? ? ? ? ? ? ? are ?searching ?for ?might ?contain ?a ?newline, then you should seriously consider using the -print0
    ? ? ? ? ? ? ? option instead of -print. ?See the UNUSUAL FILENAMES section for information about how unusual ?char-
    ? ? ? ? ? ? ? acters in filenames are handled.


    ? ? ? ?-print0
    ? ? ? ? ? ? ? True; ?print ?the full file name on the standard output, followed by a null character (instead of the
    ? ? ? ? ? ? ? newline character that -print uses). ?This allows file names that contain newlines or other types ?of
    ? ? ? ? ? ? ? white space to be correctly interpreted by programs that process the find output. ?This option corre-
    ? ? ? ? ? ? ? sponds to the -0 option of xargs.

    xargs?

    ? ? ? ?-0 ? ? Input items are terminated by a null ?character ?insteadof ?by
    ? ? ?whitespace, ?and the quotes and backslash are not special (every
    ? ? ?character is taken literally). ?Disables the end of file string,
    ? ? ?which ?istreated ?likeany other argument. ?Useful when input
    ? ? ?items might contain white space, quote ?marks, ?or ?backslashes.
    ? ? ?The ?GNU find ?-print0 ?option produces input suitable for this
    ? ? ?mode.


    總結

    以上是生活随笔為你收集整理的find -exec 与xargs 区别的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

    主站蜘蛛池模板: 在线免费观看黄色av | 亚洲av无码电影在线播放 | 精品国产一区二区三区四区精华 | 国产一区二区久久久 | 少妇毛片一区二区三区粉嫩av | 成人二区三区 | 国产成人黄色av | 糖心av| 久久99操 | 亚洲欧美精品一区二区 | h片在线观看 | 久久在线精品视频 | 国产wwwwww | 国产精品福利在线观看 | 成人免费影院 | 久久久久无码国产精品一区李宗瑞 | 国产高清精品在线 | 粉嫩av渣男av蜜乳av | 欧美人与性动交g欧美精器 国产在线视频91 | 成人免费视频免费观看 | 国产精品 欧美精品 | 99久久一区二区 | 国产乱码av | 久久a毛片 | 丰满少妇大力进入 | 献给魔王伊伏洛基亚吧动漫在线观看 | 91精品久久久久久久久久入口 | 日本精品一区二区在线观看 | 国内激情视频 | 国产aaa大片 | 日本美女毛茸茸 | 欧美不卡高清 | 这里只有精品视频 | 亚洲视频欧美视频 | 日韩av一区在线 | 中国av在线播放 | 欧美三日本三级少妇三级99观看视频 | 亚洲人 女学生 打屁股 得到 | 人妻系列一区 | 国产av人人夜夜澡人人爽 | 4438x亚洲| 在线不卡毛片 | 蜜桃臀aⅴ精品一区二区三区 | 日本系列第一页 | aa黄色片 | 日韩视频欧美视频 | 91国产视频在线播放 | fc2ppv在线播放 | 午夜精品久久久久久99热 | wwww在线观看 | 日韩www| 亚洲一区在线免费 | 凹凸av在线 | 绝顶高潮videos合集 | 二区在线视频 | 欧美一级黑人 | 涩涩屋视频 | 亚洲AV无码成人精品国产一区 | 欧美性生活视频 | 日日躁夜夜躁 | 久久新| 秋霞在线观看秋 | 快色视频 | 欧美一二三区 | 欧洲-级毛片内射 | 久久视频免费观看 | 婷婷丁香六月 | 91视频入口| 国产精品第一国产精品 | 波多野吉衣一区二区三区 | 中文字幕日韩一级 | 国产午夜一级一片免费播放 | 伦hdwww日本bbw另类 | 秋霞无码一区二区 | 色婷婷av久久久久久久 | www.色网站 | 欧美成人精品欧美一级乱黄 | 久久丫精品忘忧草西安产品 | 熟妇女人妻丰满少妇中文字幕 | 高潮网址 | 久久久久久久国产精品毛片 | 天天久久久 | 国产黄色一级大片 | 亚洲成人av电影网站 | 久久中文字幕人妻熟av女蜜柚m | 成人精品电影 | 99福利影院 | 亚洲成人一区二区 | 四虎在线精品 | 五月激情婷婷综合 | 色呦呦一区二区三区 | 亚洲蜜桃视频 | 亚州av网站 | 污视频大全 | 国产精品厕所 | 黄频在线免费观看 | 国产三级三级三级三级三级 | 中文字幕国产精品 | 五月中文字幕 |