I am in: GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
the script is: (note.sh)
#! /bin/bash
edit="edit"
if [[ $edit = $1 ]]
then
touch ~/.notes/"$2".txt
$EDITOR ~/.notes/"$2".txt
else
tree ~/.notes
fi
I was hoping
if I input in bash:
./note.sh
I get output as if i had typed
tree ~/.notes
But i want this script to basically accept arguments, so
if I input
./note.sh edit new_note
then if new_note.txt does not exist,
touch ~/.notes/new_note.txt
then
(Gedit for me) text editor opening new_note.txt in terminal for editing
the else statement works, but
./note.sh edit new_note
returns
./note.sh: line 10: /home/username/.notes/testnote.txt: Permission denied
It does the touch but not the editor. What is being denied permission here?
Thanks in advance! I am very new to both shell scripting and askubuntu and much appreciate any help