Skip to content

Instantly share code, notes, and snippets.

@alecarg
Created October 30, 2019 15:34
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 alecarg/951dac3e74769ab1eda9289402a944cd to your computer and use it in GitHub Desktop.
Save alecarg/951dac3e74769ab1eda9289402a944cd to your computer and use it in GitHub Desktop.
mv recursively (to avoid files not being moved if folders don't exist)
#!/bin/bash
# mv.sh
dir="$2"
tmp="$2"; tmp="${tmp: -1}"
[ "$tmp" != "/" ] && dir="$(dirname "$2")"
[ -a "$dir" ] ||
mkdir -p "$dir" &&
mv "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment