Reputation: 3144
Say I want to touch
six files
one.html
one.css
two.html
two.css
three.html
three.css
How can I use xargs
for this? I'm looking at the man page but I'm not sure on the syntax for getting the stdin pipe.
$ echo one two three | xargs -n 1 touch $1.html $1.css // nope
Upvotes: 2
Views: 1819
Reputation: 113834
If it is important to use xargs
:
printf "%s\n" one two three | xargs -I{} touch {}.html {}.css
Upvotes: 7
Reputation: 785058
It is easier to do via shell ist:
touch {one,two,three}.{css,html}
This will create 6 files:
one.css one.html two.css two.html three.css three.html
Upvotes: 4
Reputation: 67467
alternative with for loop
for f in one two three; do touch $f.html $f.css; done
Upvotes: 1