Skip to content

Instantly share code, notes, and snippets.

@Gowiem
Created October 2, 2012 19:06
Show Gist options
  • Save Gowiem/3822579 to your computer and use it in GitHub Desktop.
Save Gowiem/3822579 to your computer and use it in GitHub Desktop.
Follow Script
# This is in my .bash_aliases:
alias flw="source ~/Programs/flw.sh"
# ~/Programs/flw.sh
#!/bin/bash
# Follow Script written by Matt Gowie
if [[ $2 && ${2-x} && $3 && ${3-x} ]]; then
FILE=$2;
DIR=$3;
echo $1;
echo $FILE;
echo $DIR;
while getopts "c:m:" opt; do
echo "Hey"
case $opt in
c)
echo "Copying file $FILE to directory $DIR, and following behind it.";
cp $FILE $DIR;
cd "$(eval $(echo echo $DIR))";
;;
m)
echo "Moving file $FILE to directory $DIR, and following behind it.";
mv $FILE $DIR;
cd "$(eval $(echo echo $DIR))";
;;
\?)
echo "Invalid option: - $OPTARG" >&2
;;
esac
done
else
echo "You forgot to include an argument somewhere... The command works as follows:
fol -c|-m file target_directory";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment