2016-08-18 76 views
1

說我要touch六個文件CONCAT字符串通過xargs的變量

one.html 
one.css 
two.html 
two.css 
three.html 
three.css 

如何使用xargs這個?我正在查看手冊頁,但我不確定獲取stdin管道的語法。

$ echo one two three | xargs -n 1 touch $1.html $1.css // nope 
+1

'max xargs' .... –

回答

3

這是比較容易通過shell IST做:

touch {one,two,three}.{css,html} 

這將創建6個文件:

one.css one.html two.css two.html three.css three.html 
1

替代與循環

for f in one two three; do touch $f.html $f.css; done 
1

如果是重要的是使用xargs

printf "%s\n" one two three | xargs -I{} touch {}.html {}.css