I recently did an intensive course on linux and they did a little bit of bash scripting. I didnt really learn much I didnt know, apart from how to finger people. However, I would like to
1)Say I have a command
route add default gw "$i" wlan0
or something similar (with the correct santax). How can I make sure the command has worked?
For example, if it hasnt, route tends to return "unknown host". Is there anyway of tracking this. I tried shoving it though grep, but the if command and an = dont seem to work well with grep and
if route add defaul gw "$i" wlan0 | grep "unknown host" then echo "uh-oh"
doesnt work. That is one thing I would really like to know how to do.
2) save the output of a command to a variable eg.
so I can use it in my backup scripts to delete the old backups.
3)I want to do some intensive parsing of an output of a command, is is possible to check if say the first 3 characters are equal to something etc etc. I need this to check my WLAN configuration.
I guess this is all in the manuals (so please, no RTFM), but I did do a man on bash and there was nothing for parsing what a command outputs. Unfortunately, I dont have access to any books, as I'm not at home.