I know that a single dash goes with one character when we set options using getopt or optparse. but is there anyway to use a single dash with more than one character, like -apply
?
I know that a single dash refers to a short name, and conventionally people use one character for it. but there are some commands (eg, find -printf
) that use long name with a single dash.
Does anyone know how to use long name with a single dash in bash on Linux (using getopt
or optparse
other bash tools)?
cp
,ls
,ps
andtar
) accept long names with single hyphens (so you can saycp -archive -dereference -recursive
in your shell scripts), or is it about writing new programs to accept a find-like syntax (which will create a painful user experience, because it’s a non-standard user interface that is incompatible with 95% of the system)? – G-Man Says 'Reinstate Monica' Aug 25 '16 at 04:29if (strcmp(argv[1],"-foo") == 0) …
. (If you have more than a few options, you should put them in an array:strcmp(argv[1],myopts[i]) …
.) – G-Man Says 'Reinstate Monica' Aug 26 '16 at 07:44