#!/bin/sh #################### # Name: move.sh # Lisc: ISC # Main: jadedctrl # Desc: Move your bloody pieces! ##################### na=0 force=0 for argument in $@ do case $argument in -f) force=1 ;; *) if [ $na -eq 1 ] then move=$argument na=0 else if echo $argument | grep "," > /dev/null then move=$argument else file=$argument fi fi ;; esac done origin=$(echo $move | awk -F\- '{print $1}') dest=$(echo $move | awk -F\- '{print $2}') if grep $dest $file > /dev/null then if [ $force -eq 1 ] then sed 's/'"$origin"'/'"$dest"'/' $file > $file.new mv $file.new $file else sed 's/'"$dest"'/0,0/g' $file > $file.new sed 's/'"$origin"'/'"$dest"'/' $file.new > $file fi else sed 's/'"$origin"'/'"$dest"'/' $file > $file.new mv $file.new $file fi