Skip to content

Instantly share code, notes, and snippets.

@codeniko
Created December 26, 2014 04:08
Show Gist options
  • Save codeniko/77971214a513693d25f9 to your computer and use it in GitHub Desktop.
Save codeniko/77971214a513693d25f9 to your computer and use it in GitHub Desktop.
Short script to move all non-dir files to a dir specified as the argument
#!/bin/bash
scriptname='mvfiles.sh'
if [ "$#" -ne 1 ]; then
/bin/echo "Pass in destination dir as argument"
exit 1
else
/bin/echo "$(/bin/ls -l | /bin/egrep '^-' | /usr/bin/tr -s ' ' | /usr/bin/cut -d ' ' -f 9-)" | while read line; do if [ "${line}" != "${scriptname}" ]; then /bin/mv "${line}" "${1}"; fi done
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment