0

I have a filename stored in $file.

I need to delete some contents from that file for some calculation. But the original file should not be modified. So I am looking for a way to create a duplicate copy of that file to modify, and then delete it later. Is there a way to create a file with command like "$filename+2" or something like that? How do I go about doing this?

2
  • what about cp ${filename} ${filename}.copy? Commented May 26, 2014 at 8:09
  • was looking for something like this. thanks! Commented May 26, 2014 at 8:46

1 Answer 1

1

Use cp as already mentioned but consider using mktemp to create the temp filename.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.