Skip to content

Instantly share code, notes, and snippets.

@marek-saji
Created January 22, 2019 09:33
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 marek-saji/5c58109ffb3a04f150783489d9a4319c to your computer and use it in GitHub Desktop.
Save marek-saji/5c58109ffb3a04f150783489d9a4319c to your computer and use it in GitHub Desktop.
rmv ()
{
if [ "$#" -lt 2 ]; then
echo "Usage: rmv [RSYNC_OPTIONS] SOURCE... TARGET";
return 64;
fi;
local argv=("$@");
local target="${argv[${#argv[@]}-1]}";
unset "argv[${#argv[@]}-1]";
[ -e "${target}" ] || mkdir -p "${target}";
rsync --remove-source-files -PaX --info=progress2 "${argv[@]}" "${target}/" || return 1;
while [ "-" = "${argv:0:1}" ]; do
unset "argv[0]";
done;
find "${argv[@]}" -empty -type 'd' -delete
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment