Must copy and rename file

Hi all i was asked to find the terminal command that will make a copy of a file lets call it program3.cpp and give to the copy the name homework6.cpp. After that you will have two files with different names, but identical contents.

I know how to copy the file but i cant figure out how to create a second identical file with a different name. All help is appreciated. Thanks!

1

2 Answers

Copy and rename in the same time (also change filename, not only path):

cp program3.cpp homework6.cpp

Rename only:

mv program3.cpp homework6.cpp
4

If you want to have the files permanently linked use the ln command instead of cp

ln program3.cpp homework6.cpp

This puts a file descriptor (hard link) under the name homework6.cpp to the same file location as program3.cpp

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like