chicharito
chicharito

Reputation: 1087

How do I make cp give an error if a file doesn't exist

When i type command

cp notExistsFile.txt ~/Desktop/

its gives an error: "cp: cannot stat `notExistsFile.txt': No such file or directory"

is "cp command" have any option such that if file doesn not exits it wont give any error , it just skip it.

i am performing this from shell script

Upvotes: 0

Views: 1326

Answers (1)

Pradheep
Pradheep

Reputation: 3819

You can always redirect the standard error to /dev/null

cp notExistsFile.txt ~/Desktop/ 2>/dev/null

Upvotes: 2

Related Questions