From c9247b04526ed754aa43f3f889bccb564c7a20ba Mon Sep 17 00:00:00 2001 From: jadedctrl Date: Thu, 30 Mar 2017 23:24:38 -0500 Subject: [PATCH] Removed hypothetical alg. notation support --- move.sh | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/move.sh b/move.sh index 47d5575..e4798ed 100644 --- a/move.sh +++ b/move.sh @@ -8,15 +8,10 @@ ##################### na=0 -algebraic_notation=0 force=0 for argument in $@ do case $argument in - -a) - na=1 - algebraic_notation=1 - ;; -f) force=1 ;; @@ -28,7 +23,6 @@ do else if echo $argument | grep "," > /dev/null then - algebraic_notation=0 move=$argument else file=$argument @@ -39,22 +33,19 @@ do done -if [ $algebraic_notation -eq 0 ] +origin=$(echo $move | awk -F\- '{print $1}') +dest=$(echo $move | awk -F\- '{print $2}') +if grep $dest $file > /dev/null then - origin=$(echo $move | awk -F\- '{print $1}') - dest=$(echo $move | awk -F\- '{print $2}') - if grep $dest $file > /dev/null + if [ $force -eq 1 ] 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 + 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