2016-08-18 109 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