mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

wikiok (412B)


      1 #!/bin/bash
      2 
      3 FILE="$1"
      4 cd "$HOME/todo/wiki"
      5 
      6 if grep '^OK: ' $FILE > /dev/null
      7 then
      8   if grep '^OK: yes$' $FILE > /dev/null
      9   then
     10     sed -i 's/^OK: yes$/OK: no/' $FILE
     11   else 
     12     sed -i 's/^OK: .*/OK: yes/' $FILE
     13   fi
     14 else
     15   # Remove blank lines from the end of a file:
     16   # https://unix.stackexchange.com/a/552195
     17   sed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}' $FILE
     18   echo >> $FILE
     19   echo "OK: yes" >> $FILE
     20 fi
     21