copy a file to a destination with different names

11,330
for i in {b,c,d}; do cp /path/to/directory/a.txt /path/to/file/$i.txt; done
Share:
11,330

Related videos on Youtube

tyler durden
Author by

tyler durden

Updated on September 18, 2022

Comments

  • tyler durden
    tyler durden almost 2 years

    I want to copy a text file to a directory with multiple names with curly braces:

    cp /path/to/file/a.txt /path/to/file/{b,c,d}.txt
    

    But it gives me the error: target '/path/to/directory/d.txt' is not a directory

  • tyler durden
    tyler durden almost 8 years
    i'm really new to this. it didn't work, no error occurred, but there is no files inside the directory. should it be inside a script?
  • tyler durden
    tyler durden almost 8 years
    sorry, my bad, it worked, thanks for the answer!!