I have a list of files stored in txt file../test7./test4./test1./test5./test6./test10./test8./test2./test9./test3I want to run a command on all those files but I want to sleep 1 second after each two files are processed, eg:cp ./test1 test1-backupcp ./test2 test2-backupsleep 1cp ./test3 test3-backupcp ./test4 test4-backupsleep 1...cp ./test9 test9-backupcp ./test10 test10-backupIs there a way to achieve this by bash script? I would like to parametrize the amount of commands executed by 1 iteration (calling sleep 1).Also another problem is that real list of files has hundreds thousands of lines.
bash execute command for X arguments at a time
bash;arguments;limit
I assume you're not describing your real-world scenario: not only do you want to copy hundreds of thousands of files, but you want to sleep for hundreds of thousands of seconds... wtf?!?Anyway:while IFS= read -r file1      IFS= read -r file2do    cp $file1 ${file1##*/}-backup    cp $file2 ${file2##*/}-backup    sleep 1done < inputFile