Questions tagged [options]
Passing options like -l or --word to commands, or parsing them in scripts.
348 questions
1 vote
1 answer
94 views
Bash: only the first long option is being processed [closed]
Suppose we have the file ./testing with contents #!/bin/bash # Flags # Source: https://stackoverflow.com/a/7948533/31298396 TEMP=$(getopt -o ''\ --long first,second \ -...
2 votes
1 answer
111 views
Bash: function in a script with flags
Using https://stackoverflow.com/a/7948533/31298396, we can implement flags for a script testing as follows: #!/bin/bash # Flags # Source: https://stackoverflow.com/a/7948533/31298396 TEMP=$(getopt ...
1 vote
1 answer
423 views
Shell script with getopt for short and long options -handling option with and without argument
Wanted to run a script -- with option ./myscript.sh -a -g test -- without option ./myscript.sh -a -g The script looks like in below snippet, but don't see below script working correctly. The getopt ...
0 votes
2 answers
187 views
passing long positional arguments in bash script
I would like to pass long arguments to script, and referred this link. I created this my_script: #!/usr/bin/env bash # # Adapted from https://www.shellscript.sh/examples/getopt/ # set -euo pipefail ...
1 vote
4 answers
224 views
Need shell script help - processing the same option multiple times
So I've ran into a bit of a wall, I have an option in my script that calls a function which allows me to specify a file/directory and then I want to parse that output into a menu tool (using dmenu in ...
5 votes
4 answers
994 views
Pass multiple files as a single option
I'm trying to build a wrapper to execute a tool multiple times, then concatenate some of the results. I'd like to pass two sets of files to my wrapper script, then run the tool for each pair of files. ...
1 vote
2 answers
108 views
The ambiguous principles that guide the lsblk utility in removing duplicates of displayed records
Linux Mint 20.3 lsblk -V lsblk from util-linux 2.34 Let's find an explanation for the ambiguous behavior of the lsblk utility applied with the -E option. Here is the output without applying the -E ...
4 votes
2 answers
846 views
Are Shell Script --long-options POSIX compatible?
In almost all POSIX specifications (e.g. ls), there are only short options (e.g. -A , -a , etc). In common shells like Bash, long options (e.g. --all , --almost-all , etc) are very common. And it is ...
0 votes
1 answer
113 views
zsh auto completion of cp options doesn't list all of them
I've been working on setting my autocmp following this guide https://thevaluable.dev/zsh-install-configure-mouseless/. I'm on a MacOS environment but for some reason when I try to autocomplete options ...
0 votes
1 answer
231 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 "...
11 votes
1 answer
3k 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 ...
0 votes
0 answers
84 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 ...
0 votes
1 answer
91 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
552 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 ...
1 vote
1 answer
130 views
Could someone explain when I would use sync -d over sync with no options?
I'm looking at an online man page for the sync command and I can't quite figure out the intended use of the -d or --data option. Is it faster? Does it have any noticeable effect? Or is it something ...