Guys
I'm doing RH124 and on the Guided Exercise: Controlling Job there is a simple bash script
#!/bin/bash
while true; do
echo -n "$@ " >> ~/control_outfile
sleep 1
done
So I make it executable and when I try and run it I get
line 5: syntax error near unexpected token 'done'
Any ideas where I'm going wrong?
Thanks
Ian
Okay, so it seems to have been a typing error, but I dont see where. recreating it seems to work fine.
Thanks
Ian
I just copied-pasted the code and it works fine for me as well
~~~
$ cat test.sh
#!/bin/bash
while true; do
echo -n "$@ " >> ~/control_outfile
sleep 1
done
$ ./test.sh this is a test
^C
$ cat ~/control_outfile
this is a test this is a test this is a test $
~~~
okay, so a bit more info, when you type it, it doesn't process the auto indent, only after the file, with some content entered, can you make it executable and then the indents work on pressing return properly.
AFAIK, Bash doesn't require indentation.
As you can see, i just copied pasted and it worked fine (The browser didn't even mess up the double quotes)
I guess there was a hidden character typed by mistake and it wasn't copied at the browser.
If you still have the original file, you can see the hidden characters with ":set list" in Vi(m)
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.