Search code examples
sedgrepfile-renamefilelist

Complex Grep Issue


I have a list full of filenames (in each line is one filename). How can I copy a file (for e.g. text.txt) multiple times and rename it (example1.txt, example2.txt so on). At the end I want multiple files with the content of text.txt but with the filenames of my list. Is this possible?


Solution

  • while read line; do
        cp text.txt "$line"
    done < text.txt 
    

    You loop over all the lines in the file, and for each filename you invoke a separate cp command.