Learning Bash
Hi all,
This post has moved. Sorry for not redirecting you myself! WordPress.com is a bit dumb when it comes to that.
http://talesofacoldadmin.com/?page_id=11
Or click on the picture of spock :)
This post has moved. Sorry for not redirecting you myself! WordPress.com is a bit dumb when it comes to that.
Or click on the picture of spock :)
November 8, 2009 at 11:29 AM
This is a good quick primer. It’s shorter and less complete than both the bash scripting handbook and the bash manpage, but those could each be seen as assets as well as detriments.
You may want to include a link to the Advanced Bash Scripting Guide (http://tldp.org/LDP/abs/html/) as well as recommend people read ‘man bash’ for more information.
Also, it would probably be good to explain the difference between
. /path/to/script
and just
/path/to/script
Overall, good coverage of 80-90% of everything most people use in scripts. Cool. I added your blog to my google reader. I’m looking forward to more content in the future!
–Matt
PS – got here from Reddit
November 8, 2009 at 1:33 PM
Bash arithmetic:
i=1
j=2
k=$((i+j))
Inside the double parens, you don’t need $ signs to denote variables.
Same with the arithmetic conditionals:
if (( i < j )) ; then ; fi
November 8, 2009 at 5:14 PM
Thanks for clarifying this! I’ve got quite a bit of editing to do. Thank you to reddit!
November 8, 2009 at 7:31 PM
Nice post!
The if statement at the start of “Part 4.) Loops” shouldn’t really be there. The if statement is a conditional statement, not a loop.
You should check out Classic Shell Scripting from O’Reilly. Not alone is it my favourite shell scripting book, but I think it is one of my favourite tech books ever. Well worth a read.
Keep up the good work!
November 8, 2009 at 7:34 PM
Thanks for pointing that out! I got a similar comment on reddit and i was literally fixing this till my iphone told me i had another comment. lol
November 8, 2009 at 7:35 PM
[...] Bash shortcuts « Tales From a Cold Network Admin (tags: bash shell scripting) [...]
November 9, 2009 at 11:05 PM
[...] Bash shortcuts « Tales From a Cold Network Admin (tags: bash linux shell tutorial programming unix scripting sysadmin) [...]
November 10, 2009 at 1:33 PM
Yay. Yet another bash tutorial… For a (hopefully) comprehensive list of slightly longer and more complete bash tutorials, along with reviews and rating by people that actually know bash very well, see:
http://www.bash-hackers.org/wiki/doku.php/scripting/tutoriallist
November 10, 2009 at 4:10 PM
You might want to note that $USER is not always guarenteed to get the user name. It is only set in login shells, although there may be exceptions to this, so it is useful to know $LOGNAME which will also be the user name but is set in non-login shells (cron). I’m sure there are probably exceptions for LOGNAME as well :)
November 11, 2009 at 10:06 AM
[...] Learning Bash « Tales From a Cold Network Admin (tags: bash linux scripting shell reference tutorial programming unix) [...]