Lost In Cyberia Posted May 27, 2013 Posted May 27, 2013 Hey guys, another question. What determines the separation of tack options when using bash? For example in a few of the haktips, Darren separates his switches like lsof -i -n -P but in others he groups them together like: aircrack -nG Just examples, but yet, what causes you to be able to group them with just 1 minus sign, or separate them out? Or is it just a preference of the moment? Cheers! Quote
Sebkinne Posted May 27, 2013 Posted May 27, 2013 Depends on how it has been implemented by the developer. Quote
Jason Cooper Posted May 29, 2013 Posted May 29, 2013 Most standard *nix programs use the getopt library to parse the parameters on the command line. If they have used the getopt library then you will be able to merge any switch parameters (so "ls -l -t -o -r" can become "ls -ltor"). If you have a parameter that requires and argument you can't merge it into the middle of a merged group of switches as then it will think the rest of the switches are the argument, though you can merge it on the end of the group. e.g. sed -er 's/:/\t/g' /etc/passwd doesn't work, but sed -re 's/:/\t/g' /etc/passwd does. Wethere you should merge switches or not, assuming there is no company policy you have to follow, really comes down to personal preference. When scripting just use whichever makes the script easiest to read (which may be to use long opts where available as they tend to be more descriptive). Quote
Lost In Cyberia Posted May 30, 2013 Author Posted May 30, 2013 Most standard *nix programs use the getopt library to parse the parameters on the command line. If they have used the getopt library then you will be able to merge any switch parameters (so "ls -l -t -o -r" can become "ls -ltor"). If you have a parameter that requires and argument you can't merge it into the middle of a merged group of switches as then it will think the rest of the switches are the argument, though you can merge it on the end of the group. e.g. sed -er 's/:/\t/g' /etc/passwd doesn't work, but sed -re 's/:/\t/g' /etc/passwd does. Wethere you should merge switches or not, assuming there is no company policy you have to follow, really comes down to personal preference. When scripting just use whichever makes the script easiest to read (which may be to use long opts where available as they tend to be more descriptive). Thanks! Makes sense! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.