{ "version": "https://jsonfeed.org/version/1.1", "user_comment": "This feed allows you to read the posts from this site in any feed reader that supports the JSON Feed format. To add this feed to your reader, copy the following URL -- https://matoken.org/blog/tag/xargs/feed/json/ -- and add it your reader.", "home_page_url": "https://matoken.org/blog/tag/xargs/", "feed_url": "https://matoken.org/blog/tag/xargs/feed/json/", "language": "ja", "title": "xargs – matoken's blog", "description": "Is there no plan B?", "icon": "https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9.jpeg", "items": [ { "id": "http://matoken.org/blog/?p=1923", "url": "https://matoken.org/blog/2018/06/11/do-not-execute-when-there-is-no-execution-result-with-xargs/", "title": "xargs\u3067\u5b9f\u884c\u7d50\u679c\u304c\u7121\u3044\u3068\u304d\u306f\u5b9f\u884c\u3057\u306a\u3044", "content_html": "

\u3088\u304ffind\u30b3\u30de\u30f3\u30c9\u3068xargs\u30b3\u30de\u30f3\u30c9\u3092\u7d44\u307f\u5408\u308f\u305b\u307e\u3059\u304c\uff0cfind\u306e\u7d50\u679c\u304c0\u306e\u3068\u304d\u3067\u3082xargs\u306f\u52d5\u3044\u3066\u30d5\u30a1\u30a4\u30eb\u304c\u306a\u3044\u306e\u3067\u30a8\u30e9\u30fc\u304c\u51fa\u529b\u3055\u308c\u3066\u3057\u307e\u3044\u307e\u3059\uff0e

\n
$ find . -name 'hoge' -print | wc -l\r\n\r\n0\r\n\r\n$ find . -name 'hoge' -print | xargs flickcurl upload\r\n\r\nflickcurl: Minimum of 1 arguments for command `upload'\r\n\r\n  USAGE: flickcurl upload FILE [PARAMS...]\r\n\r\nTry `flickcurl --help' for more information.\r\n
\n

xargs\u3092\u4f7f\u308f\u306a\u3044\u3067find\u306e-exec\u3067\u56de\u907f\u3067\u304d\u308b\u306e\u3067\u3059\u304c\uff0cxargs\u3092\u4f7f\u3044\u305f\u3044\u3067\u3059\uff0e

\n
$ find . -name 'hoge' -exec flickcurl upload {} \\;\r\n
\n

man\u3092\u307f\u308b\u3068\u305d\u306e\u3082\u306e\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u3042\u308a\u307e\u3057\u305f\uff0e

\n
\n

-r, –no-run-if-empty
\n If the standard input does not contain any nonblanks, do not run the command. Normally, the command is run once even if there is no input. This option is a
\n GNU extension.

\n
\n

\u65e9\u901f\u8a66\u3057\u3066\u307f\u308b\u3068\u3046\u307e\u304f\u884c\u304d\u307e\u3057\u305f :)

\n
$ find . -name 'hoge' -print | xargs -r flickcurl upload\r\n
\n", "content_text": "\u3088\u304ffind\u30b3\u30de\u30f3\u30c9\u3068xargs\u30b3\u30de\u30f3\u30c9\u3092\u7d44\u307f\u5408\u308f\u305b\u307e\u3059\u304c\uff0cfind\u306e\u7d50\u679c\u304c0\u306e\u3068\u304d\u3067\u3082xargs\u306f\u52d5\u3044\u3066\u30d5\u30a1\u30a4\u30eb\u304c\u306a\u3044\u306e\u3067\u30a8\u30e9\u30fc\u304c\u51fa\u529b\u3055\u308c\u3066\u3057\u307e\u3044\u307e\u3059\uff0e\n$ find . -name 'hoge' -print | wc -l\r\n\r\n0\r\n\r\n$ find . -name 'hoge' -print | xargs flickcurl upload\r\n\r\nflickcurl: Minimum of 1 arguments for command `upload'\r\n\r\n USAGE: flickcurl upload FILE [PARAMS...]\r\n\r\nTry `flickcurl --help' for more information.\r\n\nxargs\u3092\u4f7f\u308f\u306a\u3044\u3067find\u306e-exec\u3067\u56de\u907f\u3067\u304d\u308b\u306e\u3067\u3059\u304c\uff0cxargs\u3092\u4f7f\u3044\u305f\u3044\u3067\u3059\uff0e\n$ find . -name 'hoge' -exec flickcurl upload {} \\;\r\n\nman\u3092\u307f\u308b\u3068\u305d\u306e\u3082\u306e\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u3042\u308a\u307e\u3057\u305f\uff0e\n\n-r, –no-run-if-empty\n If the standard input does not contain any nonblanks, do not run the command. Normally, the command is run once even if there is no input. This option is a\n GNU extension.\n\n\u65e9\u901f\u8a66\u3057\u3066\u307f\u308b\u3068\u3046\u307e\u304f\u884c\u304d\u307e\u3057\u305f :)\n$ find . -name 'hoge' -print | xargs -r flickcurl upload", "date_published": "2018-06-11T08:21:03+09:00", "date_modified": "2018-06-11T08:21:03+09:00", "authors": [ { "name": "matoken", "url": "https://matoken.org/blog/author/matoken/", "avatar": "https://secure.gravatar.com/avatar/38f5f3b575c5eb45cda6aa659bca119ac7a5e16b46565e869d0030e3bd66981d?s=512&d=mm&r=g" } ], "author": { "name": "matoken", "url": "https://matoken.org/blog/author/matoken/", "avatar": "https://secure.gravatar.com/avatar/38f5f3b575c5eb45cda6aa659bca119ac7a5e16b46565e869d0030e3bd66981d?s=512&d=mm&r=g" }, "tags": [ "find", "xargs", "\u672a\u5206\u985e" ] }, { "id": "http://matoken.org/blog/?p=1237", "url": "https://matoken.org/blog/2016/02/28/convenient-d-option-that-allows-you-to-specify-the-delimiter-of-the-gnu-version-of-xargs/", "title": "GNU\u7248xargs\u306e\u533a\u5207\u308a\u6587\u5b57\u3092\u6307\u5b9a\u3067\u304d\u308b-d option\u304c\u4fbf\u5229", "content_html": "

\n

\u3088\u304f\u30b9\u30da\u30fc\u30b9\u6df7\u3058\u308a\u306e\u30d5\u30a1\u30a4\u30eb\u306a\u3093\u304b\u306e\u51e6\u7406\u306bfind -print0\u3084xargs -0\u3067NULL\u533a\u5207\u308a\u6587\u5b57\u3092\u4f7f\u3044\u307e\u3059\u304c\uff0c

\n
$ find . -type f | xargs ls
ls: ./ho \u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u305b\u3093: \u305d\u306e\u3088\u3046\u306a\u30d5\u30a1\u30a4\u30eb\u3084\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306f\u3042\u308a\u307e\u305b\u3093
ls: ge \u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u305b\u3093: \u305d\u306e\u3088\u3046\u306a\u30d5\u30a1\u30a4\u30eb\u3084\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306f\u3042\u308a\u307e\u305b\u3093
./fuga  ./piyo
$ find . -type f -print0 | xargs -0 ls
./fuga  ./ho ge  ./piyo
\n

\u4eca\u56de\u9593\u306b\u66f4\u306b\u51e6\u7406\u3092\u5165\u308c\u3066\u4f7f\u3048\u307e\u305b\u3093\u3067\u3057\u305f\uff0e
\n\u9010\u6b21\u5b9f\u884c\u3067\u3088\u304b\u3063\u305f\u3089xargs -n1 -I{} rm '{}'\u307f\u305f\u3044\u306b\u3057\u3066\u62ec\u308c\u3070\u3044\u3044\u3093\u3067\u3059\u304c\uff0c

\n
$ find . -type f -print | grep -v fuga | xargs -n1 -I{} ls '{}'
./ho ge
./piyo
\n

\u4eca\u56de\u306f\u4e00\u5ea6\u306b\u51e6\u7406\u3057\u305f\u304b\u3063\u305f\u306e\u3067\u3053\u306e\u65b9\u6cd5\u306f\u4f7f\u3048\u307e\u305b\u3093\uff0exargs\u306eman\u3092\u898b\u308b\u3068delimiter\u3092\u6307\u5b9a\u3067\u304d\u308b\u306e\u306b\u6c17\u3065\u304d\u307e\u3057\u305f\uff0e

\n
\n
   --delimiter=delim, -d delim
          Input  items are terminated by the specified character.  The specified delimiter may be a single character, a C-style character escape such as \\n, or
          an octal or hexadecimal escape code.  Octal and hexadecimal escape codes are understood as for the printf command.    Multibyte  characters  are  not
          supported.  When processing the input, quotes and backslash are not special; every character in the input is taken literally.  The -d option disables
          any end-of-file string, which is treated like any other argument.  You can use this option when the input consists of simply newline-separated items,
          although it is almost always better to design your program to use --null where this is possible.
\n

\u3068\u3044\u3046\u3053\u3068\u3067\u6539\u884c(\\n)\u3092\u6307\u5b9a\u3057\u3066\u3084\u308a\u305f\u304b\u3063\u305f\u3053\u3068\u304c\u5b9f\u73fe\u3067\u304d\u307e\u3057\u305f :)

\n
$ find . -mmin -1440 -type f -print0 | xargs -0n1 file | grep -i audio | cut -f1 -d: | xargs -d\\\\n ls -1tr
\n

\n", "content_text": "\u3088\u304f\u30b9\u30da\u30fc\u30b9\u6df7\u3058\u308a\u306e\u30d5\u30a1\u30a4\u30eb\u306a\u3093\u304b\u306e\u51e6\u7406\u306bfind -print0\u3084xargs -0\u3067NULL\u533a\u5207\u308a\u6587\u5b57\u3092\u4f7f\u3044\u307e\u3059\u304c\uff0c\n$ find . -type f | xargs lsls: ./ho \u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u305b\u3093: \u305d\u306e\u3088\u3046\u306a\u30d5\u30a1\u30a4\u30eb\u3084\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306f\u3042\u308a\u307e\u305b\u3093ls: ge \u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u305b\u3093: \u305d\u306e\u3088\u3046\u306a\u30d5\u30a1\u30a4\u30eb\u3084\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306f\u3042\u308a\u307e\u305b\u3093./fuga  ./piyo$ find . -type f -print0 | xargs -0 ls./fuga  ./ho ge  ./piyo\n\u4eca\u56de\u9593\u306b\u66f4\u306b\u51e6\u7406\u3092\u5165\u308c\u3066\u4f7f\u3048\u307e\u305b\u3093\u3067\u3057\u305f\uff0e\n\u9010\u6b21\u5b9f\u884c\u3067\u3088\u304b\u3063\u305f\u3089xargs -n1 -I{} rm '{}'\u307f\u305f\u3044\u306b\u3057\u3066\u62ec\u308c\u3070\u3044\u3044\u3093\u3067\u3059\u304c\uff0c\n$ find . -type f -print | grep -v fuga | xargs -n1 -I{} ls '{}'./ho ge./piyo\n\u4eca\u56de\u306f\u4e00\u5ea6\u306b\u51e6\u7406\u3057\u305f\u304b\u3063\u305f\u306e\u3067\u3053\u306e\u65b9\u6cd5\u306f\u4f7f\u3048\u307e\u305b\u3093\uff0exargs\u306eman\u3092\u898b\u308b\u3068delimiter\u3092\u6307\u5b9a\u3067\u304d\u308b\u306e\u306b\u6c17\u3065\u304d\u307e\u3057\u305f\uff0e\n\n   --delimiter=delim, -d delim          Input  items are terminated by the specified character.  The specified delimiter may be a single character, a C-style character escape such as \\n, or          an octal or hexadecimal escape code.  Octal and hexadecimal escape codes are understood as for the printf command.    Multibyte  characters  are  not          supported.  When processing the input, quotes and backslash are not special; every character in the input is taken literally.  The -d option disables          any end-of-file string, which is treated like any other argument.  You can use this option when the input consists of simply newline-separated items,          although it is almost always better to design your program to use --null where this is possible.\n\u3068\u3044\u3046\u3053\u3068\u3067\u6539\u884c(\\n)\u3092\u6307\u5b9a\u3057\u3066\u3084\u308a\u305f\u304b\u3063\u305f\u3053\u3068\u304c\u5b9f\u73fe\u3067\u304d\u307e\u3057\u305f :)\n$ find . -mmin -1440 -type f -print0 | xargs -0n1 file | grep -i audio | cut -f1 -d: | xargs -d\\\\n ls -1tr", "date_published": "2016-02-28T04:47:22+09:00", "date_modified": "2016-02-28T04:47:22+09:00", "authors": [ { "name": "matoken", "url": "https://matoken.org/blog/author/matoken/", "avatar": "https://secure.gravatar.com/avatar/38f5f3b575c5eb45cda6aa659bca119ac7a5e16b46565e869d0030e3bd66981d?s=512&d=mm&r=g" } ], "author": { "name": "matoken", "url": "https://matoken.org/blog/author/matoken/", "avatar": "https://secure.gravatar.com/avatar/38f5f3b575c5eb45cda6aa659bca119ac7a5e16b46565e869d0030e3bd66981d?s=512&d=mm&r=g" }, "tags": [ "Linux", "xargs" ] } ] }