Skip to content

Instantly share code, notes, and snippets.

@schnell18
Last active August 29, 2015 13:57
Show Gist options
  • Save schnell18/9733270 to your computer and use it in GitHub Desktop.
Save schnell18/9733270 to your computer and use it in GitHub Desktop.
Copy file unless it does not already exist in target
SRC=/mnt/data/src1
TRG=/mnt/data/trg1
IFS=$'\n'
for f in $(ls -1 $SRC)
do
if [[ -d $TRG/$f || -f $TRG/$f ]]; then
echo "$f already exists!"
else
echo "Moving $f..."
mv "$SRC/$f" $TRG
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment