Make a copy of a file and give it a different name mac terminal

Doug Fir picture Doug Fir · May 5, 2015 · Viewed 44.4k times · Source

Mac.

I'm in a directory dogs/scripts/cats.

Within this directory there is a file bla.txt.

I would like to make a copy of bla.txt called bla2.txt and keep it in the same directory.

How do I do that?

cp bla.txt dogs/scripts/cats

'bla.txt' and `dogs/scripts/cats/bla.txt' are the same file

Answer

Mureinik picture Mureinik · May 5, 2015

cp can get a name of a target file:

cp bla.txt ./bla2.txt

Or even simpler, as Mark noted:

cp bla.txt bla2.txt