mybin

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

wikifolder (347B)


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