I've been trying to create a Bash shell script that would create and alter a file called list
. Effectively, my goal with the program is to append names to a list, creating the file with a header (if necessary).
However, the script currently fails at one particular point: Whenever I run the script again, the old name disappears and is replaced by the name that was just entered. How can I solve this?
My script:
#!/bin/bash
#Please sign your name here.
echo "Hi, what's your name?"
read name
echo "Hi $name, welcome to the Linux course!"
echo Course Attendees > list
echo $name >> list
Example of problem:
$ bash list.sh
Hi, what's your name?
Test
Hi Test, welcome to the Linux course!
$ cat list
Course Attendees
Test
$ bash list.sh
Hi, what's your name?
Test2
Hi Test, welcome to the Linux course!
$ cat list
Course Attendees
Test2
while
loops or similar for Bash. – Kaz Wolfe Dec 30 '16 at 22:27