How can I make 5 copies of one file easily?
Solution 1:
Try this
for f in {1..5}; do cp my.jpg my$f.jpg; done
(don't have bash here to try it myself)
Solution 2:
Here is a way to do it without a for
loop and without the risks of using eval
:
printf '%s\n' {1..5} | xargs -I {} cp my.jpg my-{}.jpg
It's still effectively a loop.
Solution 3:
Try tee
:
tee <my.jpg >/dev/null my-{1..5}.jpg
Or parallel
:
parallel cp my.jpg ::: my-{1..5}.jpg
Solution 4:
You can do it without a loop.. using tee
and {}
brace expansion.
EDIT: (ammended as per Dennis Williamson's comment:
For a file named "my-.jpg"
pre="my-"; suf=".jpg"
<"$pre$suf" tee "$pre"{1..5}"$suf" >/dev/null