I a new to bash but I am trying to write a bash script which does the following:
write_to_file()
{
#check if file exists
# if not create the file
# else open the file to edit
# go in a while loop
# ask input from user
# write to the end of the file
# until user types ":q"
}
If anyone can point out the literature, I would be very thankful
Thanks
Update: As it’s a bash question, you should try this first. 😉
To understand what is going on, read about bash’s IO redirection, heredoc syntax and the cat command
As you see above, there are many ways to do it. To explain some more bash commands I’ve prepared the function also in the way you’ve requested it: