I'm try to copy files from a location (/home/ppaa/workspace/partial/medium) to another location (/home/ppaa/workspace/complete) using bash shell scripting in Linux.
This is my code:
#!/bin/bash -u
MY_BASE_FOLDER='/home/ppaa/workspace/'
MY_TARGET_FOLDER='/home/ppaa/workspace/complete/'
cp $MY_BASE_FOLDER'partial/medium/*.*' $MY_TARGET_FOLDER
return=$?
echo "return: $return"
The folders exists and the files are copied but the value of return variable is 1. Whats wrong?
cpreturns error code 0 on success and 1 on failure.cpwill exit with non-zero status if it is unable to copy any of the specified files. That could happen for any number of reasons, but one reasonably likely one is that your source glob matches one or more directories. Non-recursivecpwill not copy directories, and will exit with status 1 if asked to do so. It will still copy the files it can, however.cp: none-such : not found. OR are you redirecting std-err to/dev/nullsomeplace you are not showing us? i.e..... 2> /dev/null. Good luck.