function delete(){ # Requires: $NOTE, $NOTE_DIR # Given a valid $NOTE, delete removes $NOTE from sns. if [ -e "$NOTES_DIR/$NOTE" ]; then rm "$NOTES_DIR/$NOTE" printf " - %s\n" "Deleted note: ${NOTE%.*}." #Cleanup empty notebooks/sections] find "$NOTES_DIR" -mindepth 1 -type d | tac |\ while read -r DIR ; do if [ ! "$(ls -A $DIR)" ]; then rmdir "$DIR" fi done else >&2 printf " $RED_COLOR!$RESET_COLOR %s\n" "Note ${NOTE%.*} does not exist." fi }