Why does this simple script is not working?
Hi everyone!
I have a doubt, there is this simple script I made in arch, using nano, It worked perfectly the first time I made it, then I reinstalled my arch system, and now it doesn't work, I don't get what I am doing wrong, since I did exactly the same than the last time: Code:
ismaelvc@toybox ~ $ nano now thanks in advance. |
the first line: #!bin/bash should be #!/bin/bash
|
You need a "/" in front of the "bin/bash" at the beginning of your script. IE:
Code:
#!bin/bash Code:
#!/bin/bash |
@schneidz & suicidaleggroll:
lol thank you very much, how silly of me, but I honestly didn't notice that. greetings. |
By the way, the "&&"s (the "and" list operator) after each command aren't really necessary here. It's effect is to link two commands together so that the trailing command only executes if the previous one exits successfully.
But all of the commands you are using are so simple and stable that they will almost never fail, and there's no harmful effect involved even if they do. Just put one command on each line and save the list operators for when you really need them. You also don't need the "" quotes after the echo commands, as it defaults to printing a newline anyway. |
@David the H.: Thank you very much!
Yes I have been wondering what is the difference between ";" and "&&", but I didn't know I could do it without any of them, also thanks for pointing out "echo" default behaviour, I think I need to actually read some man pages and not just "view" them! But there are just massive ammounts of linux information out there, sometimes, I get lost, or worse confused lol! :) |
Glad to help.
";", BTW, is just the default sequencer, acting the same as a newline. When one command terminates, whatever the status, the next one is executed. It's mostly there for combining multiple commands on a single line. As for learning scripting, and Linux use in general, it just takes time. Like all other skills it becomes easier with practice, study and experience. I was just like you 10 years ago. You actually have it easier than I did; there are better resources available now. Here are a few useful bash scripting references: http://mywiki.wooledge.org/BashGuide http://mywiki.wooledge.org/BashFAQ http://mywiki.wooledge.org/BashPitfalls http://wiki.bash-hackers.org/scripting/newbie_traps http://www.linuxcommand.org/index.php http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.tldp.org/LDP/abs/html/index.html http://www.gnu.org/software/bash/manual/bashref.html http://wiki.bash-hackers.org/start http://ss64.com/bash/ I particularly recommend the BashGuide, as it covers all the basics of bash scripting in a few, easy-to-read pages, along with links to lots of other helpful advice. |
All times are GMT -5. The time now is 08:49 PM. |