If i make a script in bash how do i make it so that theres 2 parts and the second part must be executed with scriptname -argument and i also want to have --help
P.S just trying to get the forum to be bright for people to help cause it aint lit to me..
It only becomes lit when a post is new relative to the reader's last vist. So if anybody comes that hasn't seen the post it will be lit.
I don't understand the question fully. You can access a second file using
in the script.
You can access the parameters entered to the script using $1 for the first parameter, $2 for the second, etc. (the first parameter is the script name) if there are more than 9 parameters, look into the shift operator.
There's some links in the Arch WHERETO in the wiki to sites that teach you basic and advanced bash. You should have looked there first and searched google.
What i meant was if i just type in filename because its executable and in /usr/bin/ it will show somewhat like just typing pacman would.. And then filename -c would do one thing filename -r would do another and so on..
put #!/bin/sh as the first line with no whitespace before it.
then chmod a+x filename.
then you should be able to execute with ./filename.
put it in /usr/bin or anywhere in the path to executable.
i know that i need to know how to make it be able to do command -c or command -d like command will just show basically what pacman does.. command -h will show the help and command -d will do something else and so on..
Is there an easier way than doing if [ $1 = -h ]; then throughout the file but and at the end of the section end with an fi? Anyways now all i get is a
/usr/bin/kernel: line 4: [: =: unary operator expected /usr/bin/kernel: line 23: [: =: unary operator expected /usr/bin/kernel: line 115: [: =: unary operator expected how do i stop that..
Thx for that link in the wiki.. but cant stop those problems
what you are looking for is getopt and getopts..
most languages have these utilities (perl, php, etc.).
Bash does too..
"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍