rsmith
rsmith

Reputation: 161

BASH File Movement

I have BASH Function

MoveToTarget() {
    #This takes to 2 arguments: source and target
    echo ""$1"  "$2""
    cp -r "$1" "$2"
    rm -r "$1"
}

And I'm passing these values in:
First argument: (source)

/home/family/.PROGNAME/updater/update

Second argument: (target)

/home/family/Desktop/client/src

Right now, the folder /update is being moved into /home/family/Desktop/client/src creating /home/family/Desktop/client/src/update. How can I get it so the contents of /home/family/.PROGNAME/updater/update are moved into /home/family/Desktop/client/src? (Re-writing over any existing files), rather than just moving the folder?

Some additional information, the following AutoIt code accomplishes what I need.

 DirCopy($source, $target, 1)
 DirRemove($source, 1)

Upvotes: 0

Views: 126

Answers (1)

James Scriven
James Scriven

Reputation: 8134

cp -rf /home/family/.PROGNAME/updater/update/* /home/family/Desktop/client/src

or in your script:

cp -rf "$1"/* "$2"

Upvotes: 3

Related Questions