I try to duplicate a video file x times from the command line by using a for loop, I've tried it like this, but it does not work:for i in {1..100}; do cp test.ogg echo test$1.ogg; done
Duplicate file x times in command shell
shell;files;file copy
Your shell code has two issues:The echo should not be there.The variable $i is mistyped as $1 in the destination file name.To make a copy of a file in the same directory as the file itself, use cp thefile thecopyIf you insert anything else in there, e.g.cp thefile theotherthing thecopythen it is assumed that you'd like to copy thefile and theotherthing into the directory called thecopy.In your case, it specifically looks for a file called test.ogg and one named echo to copy to the directory test$1.ogg.The $1 will most likely expand to an empty string.  This is why, when you delete the echo from the command, you get test.ogg and test.ogg are the same files; the command being executed is essentiallycp test.ogg test.oggThis is probably a mistyping.In the end, you want something like this:for i in {1..100}; do cp test.ogg test$i.ogg; doneOr, as an alternativei=0while (( i++ < 100 )); do  cp test.ogg test$i.oggdone