Create multiple file copies with Tee in Linux
Wed, 15 May 2024 08:24 UTC
Image: CC BY 4.0 by cybrkyd
A recent WHYBAML (where have you been all my life) discovery is: tee for creating multiple copies of the same file in Linux.
cp works well enough if you fancy doing it multiple times…
$ cp original.txt copy.txt
…or if you like typing a lot:
$ for i in {1..10}; do cp original.txt "copy$i.ogg" ; done
tee is short and sweet:
$ tee copy{1..10}.txt < original.txt
When you run Tee will output the entire contents of the original file; silence it with >/dev/null:
$ tee copy{1..10}.txt < original.txt >/dev/null
Non-sequential copying
To make multiple copies of the file but have non-sequential names, you need to explicitly name the copies:
$ tee copy-ten.jpg copy-fifty.jpg copy-eighty.jpg < original.jpg >/dev/null
For me, this is far better than doing right-click >> copy / right-click >> paste multiple times.
»
Visitors: Loading...
