Skip to content

Instantly share code, notes, and snippets.

@gamesbook
Created Apr 19, 2021
Embed
What would you like to do?
Copy files from source directory if they already exist in destination
#!/bin/bash
for file in /src/*; do
cfile="${file##*/}"
if [ -f "/dest/${cfile}" ]
then
echo "${cfile}"
cp "/src/${cfile}" "/dest/${cfile}"
touch "/dest/${cfile}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment