Bash scripting questions
I'm starting my adventure in bash scripting, teaching myself. Now i've got alot of basics down, but there are a few things that are iffy, and I haven't came across each function in my tutorial. So here are my questions:
When echo -n "blah" is used, what purpose does -n server? Using if and elif, what purpose do -z, -x, and ! = or if ! [] serve? If you can toss any more - functions out there that will assist me that would be great. Also, for my first simple program, I am coding an iptables script. I am wanting to have the user input several ports seperated by a space. i.e: 21 22 23 113 All in one line. How would I do this? $1 $2 $3 $4 and so on, or am I way off. I just started yesterday, and I am trying to catch on quickly. Thanks for the help guys. |
man echo: -n do not output the trailing newline
Use -n when you want following output to appear on the same line. See http://www.gnu.org/software/bash/man...ref.html#SEC77 for details of -z, -x, and != [...] will match any of the enclosed characters so I'd guess ![...] would match anything except the enclosed characters. For your iptables script, do you want to prompt the user for input after the program starts or do you want the user to start the program with the port data as arguments? Either are possible (or both - you could check if command line arguments were provided and if none are given, prompt the user for input). |
Alright, thank you. I hadn't came across that reference yet, and it has what I was looking for right in it.
As for the iptables script, I would like to get user input after the program has started. That's my goal for this script. |
Code:
read [-ers] [-u fd] [-t timeout] [-a aname] [-p prompt] [-n nchars] |
All times are GMT -5. The time now is 08:03 AM. |