Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [options]

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

22 votes
8 answers
22k views

Compiling GNU/Linux with -O3 optimization

It's said that compiling GNU tools and Linux kernel with -O3 gcc optimization option will produce weird and funky bugs. Is it true? Has anyone tried it or is it just a hoax?
14 votes
2 answers
9k views

grepping for word starting with hyphen gives error: invalid option -- 't'

When I grep the man page of the find command for matches to type it returns a lot of search results that I don't want. Instead I want to use a command that returns only the search results for -type. ...
26 votes
4 answers
51k views

How do I handle switches in a shell script?

Are there some built-in tools that will recognize -x and --xxxx as switches (flags or "boolean options", rather than "ordinary arguments"), or do you have to go through all the ...
0 votes
1 answer
87 views

When and why was the single dash introduced for command line options?

Already in the 1980ies, ls -l did mostly what it does today. For a boolean option, in this case l, I hardly ever questioned why it is prefixed with a dash: without an indicator, ls l would mean "...
3 votes
2 answers
3k views

What is the `less` command line option to page to the next file at the end of the current one?

I'm sure there used to be an option in less which allowed you to page onto the next file after you reached the end of the current file, so you could just keep *space*ing through a bunch of short files ...
2 votes
3 answers
6k views

How to extract unknown arguments within a shell script?

I have a shell script that accepts a variety of options, some with arguments, some without, some short, some long. It should handle some of these options itself and pass on the rest it does not know ...
11 votes
1 answer
2k views

Why does `nice` with a negative argument (e.g. `nice -15`) increment niceness?

My nice is from GNU coreutils 9.1. I observed that nice -15 is equivalent to nice -n 15: nice # prints 0 for me, the base niceness is 0 nice -n 15 nice # prints 15, this is ...
4 votes
2 answers
3k views

Symbolic link with option

Is it possible to create a symbolic link to an executable that executes it with a certain option/argument? I know a workaround would be to create a bash script in one of the PATH directories but can ...
13 votes
3 answers
11k views

Copying image from scrot into clipboard after capture

I've grown affection to scrot as a simple screenshot utility, but it lacks one thing i would greatly appreciate--a way to copy your capture and have it in your clipboard automatically. I've added a ...
0 votes
0 answers
46 views

How to gracefully handle differences in command options between different versions?

Inspired by What is the difference between “base64 -b0” in macOS versions prior to macOS 13 (Ventura) and “base64 -i” in macOS 13 (Ventura)? Are there common ways to avoid the script breaking on a ...
74 votes
5 answers
64k views

getopt, getopts or manual parsing - what to use when I want to support both short and long options?

Currently I'm writing a Bash script which has the following requirements: it should run on a wide variety of Unix/Linux platforms it should support both short and (GNU) long options I know that ...
31 votes
2 answers
40k views

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

What's the difference between du -sh * and du -sh ./* ? Note: What interests me is the * and ./* parts.
0 votes
1 answer
48 views

What is the difference between quotes wrap around only the option value vs quotes wrap around the option name and option value?

What is the difference between quotes wrap around only the option value eg: grep --file="grep pattern file.txt" * vs quotes wrap around the option name and option value eg: grep "--...
1 vote
1 answer
116 views

What are the possible objdump demangle styles?

The manpage for objdump states: --demangle[=style] ... The optional demangling style argument can be used to choose an appropriate demangling style for your compiler. Nowhere does it mention ...
2 votes
1 answer
876 views

How does -m option work in sort command?

As sort's man page says: -m, --merge merge already sorted files; do not sort Here are my two simple text files and the result of sort command with -m option: soroush@pop-os:~/Desktop$ cat a_file....

15 30 50 per page
1
2 3 4 5
23