acer
acer

Reputation: 303

Issue with my bash script to copy files

I have written a bash file to copy files from a folder to another folder.

cp -u "{Source}" "{Destination}" 

The above one is my bash file.

The problem now is, if I give the Destination = k,then also,the bash file get executed(Normally in the destination we will give the path) and it's giving success message.It's giving success message but It's not copying file and it's just creating a file in the name k(k mean,I gave the destination as k above)

So I need to check the destination and if the destination is not properly given,I need to give error message.How to do it?

Upvotes: 0

Views: 59

Answers (1)

sunhs
sunhs

Reputation: 401

You can do this:

if [ -d "${Destination}" ]; then
    # do the copy work
else
    # echo the error message
    exit 1
fi

Upvotes: 1

Related Questions