åæè¨å®
以ä¸ã®ãããªå 容ã®ãã¡ã¤ã«ãããã¨ãã¾ã
% cat hoge.txt
a 1 x
b 2 y
c 3 z
awkã使ãã¨ä»»æã®åã®ãã¼ã¿ãåãåºãã¾ã
$2ã¨$1ã«å¤ããã¨a, b, cã«ãªãã¯ã
1
2
3
Â
ãã¡ã¤ã«ã®ä¸èº«ã使ã£ã¦ãã£ã¬ã¯ããªãä½æããã
ãã®çµæã使ã£ã¦1ã¨2ã¨3ã¨ãããã£ã¬ã¯ããªãä½ãããã¨ãã¦ã
ã¨ãã¦ã¿ãã¨ã»ã»ã»
mkdir: missing operand
Try 'mkdir --help' for more information.
zsh: done    awk '{print $2}' hoge.txt |
zsh: exit 1 Â Â mkdir -p
ã¨ããã¨ã©ã¼ãåºã¦ãã¾ãããã¾ããã§ãã
Â
ãããããã«ã¯xargsã¨ããã³ãã³ãã使ã£ã¦ããã®çµæãã³ãã³ãã«æ¸¡ãã¾ã
ããã§ãã£ã¬ã¯ããªã®ä½æãã§ãã¾ãã
Â
-Iãªãã·ã§ã³ã«ã¤ãã¦
-I {}
ã¨ããã®ã¯ãawkããã®åºåãåãåã£ã¦ãããããã¤ãå¾ã®ã©ãã«é ç½®ããããæå®ã§ãã¾ã
ã¡ãªã¿ã« {}ã¯å¥ã«ãªãã§ãOKã§ãã-Iã®å¾ã«ããæåã¨å¾ãã®æåã対å¿ãã¦ããã°OK
(texã®verb|ã¨åããããªæã)
Â
ã¨ããã¨
1_1
2_2
3_3
ã¨ãããã£ã¬ã¯ããªãã§ãã¾ãã
Â
è¤æ°ã®å¤æ°ãxargsã®å¾ã®ã³ãã³ãã«æ¸¡ãããã¨ãã¯ã©ããããä¸æ
ã¾ãå¿ è¦ãªã調ã¹ã¾ã
Â
-pãªãã·ã§ã³ã«ã¤ãã¦
ããã¯ãã©ã¤ã©ã³ããããªãã·ã§ã³
å®éã«å®è¡ããã«ãå®è¡ãããã©ãããã³ãã³ããå®è¡ããã¦ãã®ã表示ãã¦ããã
Â
Â
xargsã使ã£ãä»ã®ä¾
12 Practical Examples of Linux Xargs Command for Beginners
webã§ãã®è¨äºãç´¹ä»ããã¦ã¦èªãã ãã©ããããã»ã»ã»
ãã¶ãèªåã¯ä½¿ããã¨ã¯ãªããã