GLaDOS
GLaDOS

Reputation: 76

cp command conflicts on non-existent files

An error occurs when I ran this command on a RedHat server where data was a directory:

rm -rf data; cp -r another_dir data

An error occurs with this command:

cp: cannot create directory `data/test': File exists

This error does not always happen. Usually when I see this error I can simply rerun the commands and it would succeed. Also, changing the ; sign to a $ does not solve this problem.

I simply don't understand. How could this even be possible?

Upvotes: 0

Views: 290

Answers (1)

Alfas MP
Alfas MP

Reputation: 79

What is data? A directory or a file ? If that is a directory try rmdir data If it is a file , try rm -f data

Since rm -rf data;cp -r another_dir data is two different commands . So just try one by one and give me the result

Upvotes: 1

Related Questions