Passing options like -l or --word to commands, or parsing them in scripts

learn more… | top users | synonyms

3
votes
1answer
112 views

Why does `du -sh *` complain about invalid options?

I've searched my best through Google, but for the life of me I can't figure out what to use instead of * (asterisk) after a recent update (even Wikipedia seems to think du -sh * and du -sh * should ...
2
votes
1answer
32 views

Order between options and operands?

When using a utility program, we may specify options (and their option arguments) and/or operands. In most cases (in the sense of conforming to some standard (POSIX?)) does the order between ...
1
vote
0answers
36 views

Why is rm -r the same as rm -R?

If you look in the rm man page you see that rm -r, rm -R, and rm --recursive are all the same. -r, -R, --recursive remove directories and their contents recursively When using options, I'm ...
1
vote
2answers
41 views

how to delete file that start with “-” [duplicate]

I try to delete this file on my solaris machine rm "-Insi" rm: illegal option -- I rm: illegal option -- n rm: illegal option -- s I also try this rm "\-Insi" -Insi: No such file or directory ...
2
votes
1answer
38 views

Do you need to specify the “defaults” option in fstab?

The Arch Wiki on fstab specifies the options of / to be defaults,noatime, but on my installation the default fstab is created with the options of rw,relatime. The Arch Wiki covers the atime issues. ...
2
votes
1answer
18 views

Why did “argument can be squisehd against option” prevail over “argument is always separate”?

Inspired by the recent question Why does the specific sequence of options matter for tar command?, in which the asker learned why tar -cfv test.tar *.jpg doesn't work, I'd like to ask a followup: ...
4
votes
3answers
506 views

Why does the specific sequence of options matter for tar command?

I was trying out tar command to make archive with .tar extension. please have a look at the following series of commands I tried: $ ls abc.jpg hello.jpg xjf.jpg $ tar -cfv test.tar *.jpg tar: ...
0
votes
1answer
58 views

What does the option -C achieve in ls output?

In the man pages it says: -C list entries by columns However, I really cannot notice any difference between the output of ls or ls -C, could someone explain this to me?
3
votes
1answer
55 views

Why do some utilities parse operands before options?

According to several sources, the UNIX utility guidelines specify that operands should always be processed after options: utility_name[OPTIONS][operands...] Some older UNIX utilities are known to ...
18
votes
6answers
808 views

Is there way to see `man` document only for specified option of a command

If I want to know the meaning of wget -b, I see the manual by man wget, then search the -b option. -b --background Go to background immediately after startup. If no output file is ...
2
votes
1answer
113 views

Mapping metadata with avconv does not work

The way I understand man avconv (version 9.16-6:9.16-0ubuntu0.14.04.1), the following command should convert input.ogg to output.mp3 and carry over metadata: avconv -i input.ogg -map_metadata 0 ...
1
vote
1answer
23 views

How do I specify command invocation for a mandatory short or long option?

I'm writing a specification for a tool that needs a -f / --foo option with a mandatory argument BAR, so for example these are valid calls: tool -f BAR tool --foo BAR How do I specify this syntax in ...
13
votes
2answers
316 views

Security implications of running perl -ne '…' *

Apparently, running: perl -n -e 'some perl code' * Or find . ... -exec perl -n -e '...' {} + (same with -p instead of -n) Or perl -e 'some code using <>' * often found in one-liners ...
2
votes
2answers
850 views

Negative arguments to head / tail

Variants of this question have certainly been asked several times in different places, but I am trying to remove the last M lines from a file without luck. The second most voted answer in this ...
0
votes
2answers
26 views

why some programs needs -h and other no

I know that is not a exciting question, but yet I don't understand why some programs needs program -h and other program --help sometimes is very boring recognize it
2
votes
2answers
34 views

Is there a `--paranoid` type flag for common, potentially irreversible commands?

I'm not aware of any standard flag that is implemented. There are some git commands that let you specify a -n parameter that will show you what the command is going to do, but doesn't actually do it. ...
2
votes
1answer
51 views

Strange leading whitespace in OPTARG when using getopts

I spent quite a while researching the problem I encountered but none of the getopts tutorial say anything about the leading whitespace in OPTARG when using getopts. In bash(on Ubuntu and OSX), ...
5
votes
1answer
748 views

Provide two arguments to one option using getopts

In below code when I give option r then getopts requires one arguments: while getopts ":hr::l:" opt; do case $opt in r ) echo "Run Numbers - argument = $OPTARG " ;; l ) echo ...
2
votes
2answers
188 views

Optional arguments after or before the mandatory arguments?

I'm creating a shell script and I need it to take two mandatory arguments and one optional. How do I check that? In most scripts I've seen, the optional arguments are passed before the mandatory ones, ...
0
votes
0answers
13 views

rpm :deptype flags explained

On Fedora 20 (Heisenbug) I issed the following command … rpm --query --queryformat="%{REQUIREFLAGS:deptype}\n" --all | sort --unique --dictionary-order … to get all possible :deptype ...
0
votes
1answer
41 views

Options to a command specified in a file

How can I have some of the options to a unix command come from a file? That is the file does not contain all the options -- other options are specified elsewhere. For example I have the ...
2
votes
1answer
71 views

FAT Mountoption allow_utime explained

I trying to figure out what the following Mountoption for (v)FAT exactly does (in Linux): allow_utime=### -- This option controls the permission check of mtime/atime. 20 - If ...
3
votes
4answers
243 views

Test if command accepts a specific option

What is the preferred way to test if a command takes an option? What are the caveats? As a motivating example, at login my shell aliases grep to add several --exclude-dir options but this option is ...
1
vote
1answer
105 views

How to know DHCP options value on debian/ubuntu and other linux

How to know all DHCP options and values (on the client side, Linux Ubuntu / Debian / ArchLinux ) provided by the server. I need to pass non-standard option to the client by the DHCP option code ...
1
vote
1answer
94 views

in which units does tar --checkpoint measure?

GNU tar offers the option --checkpoint where a message should be printed each checkpointreached. Question:: In what does --checkpoint measure? My best guess is Bytes. I wasn't able to find a hint ...
2
votes
1answer
36 views

Understanding passwd --keep-tokens

On GNU/Linux, I do have trouble understanding the meaning of the --keep-tokens option for passwd. As it doesn't seem to be much used as I am not able to find any examples and only online copies of man ...
13
votes
4answers
699 views

Why does ls accept duplicate switches?

I'm curious - is there a difference between ls -l and ls -lllllllllllllllllllllllllllll? The output appears to be the same and I'm confused on why ls allows duplicate switches. Is this a standard ...
5
votes
2answers
309 views

How do you get fgrep to find the literal “--help”?

fgrep --help | fgrep "--help" returns just the whole fgrep --help, how do I return just the lines that have the literal "--help" in them? The quotes don't do anything, nor does \-\-help.
2
votes
1answer
50 views

What is a command that will only show me the command syntax and options?

Is there a command which will just list all the options for a given command on one or two lines and not as long and words as man or info ?
3
votes
3answers
222 views

Interactive command usage reference: do you generally have that on Unix?

The question of why some commands rely on manpages whereas others rely on something like the --help flag for providing command usage reference is not new. There is usually a difference in scope ...
8
votes
1answer
658 views

How to append multiple lines to a file with bash, with “--” in front of string

Question very similar to How to append multiple lines to a file with bash but I want to start the file with --, and also append to the file, if possible. printf ...
35
votes
7answers
3k views

Is `-` used only with cd?

cd - can switch between current dir and previous dir. It seems that I have seen - used as arguments to other commands before, though I don't remember if - means the same as with cd. I found that - ...
1
vote
2answers
29 views

Shell is option given

I have a couple of arguments inside a list (array, e.g. $@) and I'd like to know if the option -v is in the list. In Python I would simply do: verbose = "-v" in sys.argv How do I achieve that in ...
1
vote
1answer
244 views

Debian + Linux kernel 3.12.22: “Kernel module loader” option is not available

The Debian guide for compiling a kernel says: Do not forget to select “Kernel module loader” in “Loadable module support” (it is not selected by default). If not included, your Debian installation ...
1
vote
1answer
19 views

Can't search for flags in qalter's man page?

I was trying to find out what qalter's -r flag does, but I can't search for -r when viewing the man page for it (pattern not found). Yet it's clearly there. If you scroll down a bit you'll see it. Why ...
4
votes
1answer
61 views

POSIX usage standards for requiring at least one optional arg

So, I'm writing a CLI for an API, and I ran into a point where one of the commands support has two optional arguments, id and fields I want to know how to show that these arguments are optional, BUT, ...
0
votes
1answer
75 views

Is there a command which displays options like `errexit` and `braceexpand` other than `help set`?

If you type help set, then - among other things - a list of shell options is displayed. But these options are not the same as those displayed with shopt. And different also from those displayed with ...
2
votes
1answer
20 views

Correct way to document variable length options in man pages

Sometimes I see usage information like some_utility [arg [arg [...]]] or some_utility [arg[, arg[...]]] that indicates that you can pass more than one of the same argument. I've also seen it ...
2
votes
2answers
393 views

Arguments, options and dashes

Why do console applications get the arguments started with either: a) one dash (myapp -arg1 123; ls -al) b) two dashes (myapp --arg1 123; git push origin master --force) c) without dashes at all ...
3
votes
2answers
804 views

Passing arguments to su-provided shell

man su says: You can use the -- argument to separate su options from the arguments supplied to the shell. man bash says: -- A -- signals the end of options and disables further option ...
2
votes
4answers
2k views

Parsing process command-line arguments from pargs in a shell script

I get list of PIDs in my bash scripts (Java processes) and have to analyze their command-line arguments to determine which instance of server each PID corresponds to. At the moment I do it that way ...
1
vote
1answer
416 views

bash control statment for when an option flag is used

I trying to make control statement to check on a option flag is used or not? For -o output.file if is used I would like to make equal to variable OUTPUTSUM = OUTPUTFILE and if there no -o option use ...
3
votes
2answers
537 views

Privileged mode in bash

I've used bash for years but I 've stuck with the"privileged mode" that it can be configure with the set command. For example: set -p I've read the bash man page but it's somewhat obscure. For ...
2
votes
2answers
103 views

Parsing of command line options

For I school project, I have to implement a shell/terminal app. But I am wondering how are command line options parsed, because it appears abit weird to be. For example for the command paste (and I ...
1
vote
1answer
179 views

Is there a simple way to get array of all arguments that do not begin with a hyphen?

zsh includes a powerful utility for parsing command-line options zparseopts, but for quick shell scripts and shell functions, but is there an easy way to extract the array of all command-line ...
3
votes
1answer
51 views

“mke2fs -r fs-revision-level” - how is this used?

mke2fs -r offers Set the filesystem revision for the new filesystem. Note that 1.2 kernels only support revision 0 filesystems. The default is to create revision 1 filesystems. Trying to ...
1
vote
2answers
1k views

fdisk (expert mode) options

On GNU/Linux with fdisk (util-linux 2.20.1), when using, say fdisk /dev/sda3 there are quite some options and the and even an "expert mode" (x). Most of these are explained through the m option. But ...
11
votes
2answers
3k views

What is the difference between “du -sh *” and “du -sh ./*”?

The title says it all. What's the difference between those 2 commands? NOTE: I'm more interested in the * and ./* part.
0
votes
1answer
43 views

w command: same output with(out) -u option?

According to the manpage for w: -u   Ignores the username while figuring out the current process and cpu times. To demonstrate this, do a "su" and do a "w" and a "w -u". I've tried this ...
2
votes
1answer
481 views

Automatically start an application with a modifed LD_PRELOAD?

I have an application that needs a modified LD_PRELOAD. I want to start the application using the originally provided rc script, so I can benefit from an automatically updated rc script on an update ...