41

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

Mureinik
  • 297,002
  • 52
  • 306
  • 350
Doug Fir
  • 19,971
  • 47
  • 169
  • 299

1 Answers1

56

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
Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • Thank you, knew it had to be something simple but google searches kept telling me how to copy the file to a new directory with the file having the same name – Doug Fir May 05 '15 at 16:00
  • 2
    I understand that `./` means *"the current directory"* but what's the logic of introducing that here, when `cp bla.txt bla2.txt` does exactly the same thing but more simply? – Mark Setchell May 05 '15 at 16:34
  • 1
    Tell me about it :-) :-) – Mark Setchell May 05 '15 at 16:49