Skip to content

Instantly share code, notes, and snippets.

@gamesbook
Created April 19, 2021 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gamesbook/a60c42cae94cbb815ab7eb2e4230cc96 to your computer and use it in GitHub Desktop.
Save gamesbook/a60c42cae94cbb815ab7eb2e4230cc96 to your computer and use it in GitHub Desktop.
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