Questions tagged [options]
Passing options like -l or --word to commands, or parsing them in scripts.
338
questions
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 "...
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 ...
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 ...
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 ...
1
vote
1
answer
82
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 ...
0
votes
1
answer
72
views
Duplicate boot params after grub2-mkconfig
I removed the flags 'quiet' , 'splash' , and added others in the file /etc/default/grub, applied them: grub2-mkconfig -o . After a reboot, the kernel boot flags began to double. With each 'grub2-...
8
votes
1
answer
894
views
Looking for a more permissive alternative to GNU getopt for wrapper script
I often find myself writing shell functions or shell scripts that are meant to be wrappers around other commands.
It is also frequent that I want such a wrapper to support a few flags/options. The ...
6
votes
1
answer
170
views
How can I force zsh to write automatically complete path to history?
Suppose I did some time ago cd /path/to/foo/bar and then evince file.pdf. Now if I want to open file.pdf again I have also to do both steps again (using history). However I would do it in a single ...
0
votes
3
answers
346
views
listing existing users sorted by date of creation using cut command
ASK: to use cut command to list all users to confirm a successful useradd.
ISSUE: The list was very long and I had to scroll through output to find user.
NEED: Sort by the date the user was created. ...
-1
votes
1
answer
329
views
How to check for passed options using getopts in a POSIX shell? (Report, count, and discard.)
How to check for passed options using getopts (man page) in a POSIX shell? (Report, count, and discard.)
My idea is this: Many of my scripts take no options (not even -h for help, I am transitioning ...
-1
votes
1
answer
55
views
Script is not activating the options
I'm making a script to open url by terminal and when typing:
#!/usr/bin/bash
## origin: https://www.vivaolinux.com.br/script/Abrir-arquivos-em-nova-aba-no-Firefox
##
### Se quizer que o novo link ...
1
vote
2
answers
1k
views
rm command contradictory options -i and -f
I learned that -i option is interactive mode and -f option is force model in rm command.
When I tried both options
rm -if test.txt
it did not ask me and just deleted it which means -f option overrode ...
0
votes
2
answers
356
views
Error parsing arguments for options in script Unexpected option in Shell Script
I'm trying to parsearg arguments to pass options to the script.
but it is showing the following errors Unexpected option: -u in addition to looping below:
$ gitpratico -u "<usuario_github>&...
1
vote
1
answer
75
views
install --compare is said to, in some cases, not modify the destination at all - but in which cases?
The man page for install describes the --compare option like so:
-C, --compare
compare each pair of source and destination files, and
in some cases, do not modify ...
4
votes
2
answers
4k
views
What precisely does cp -b (--backup) actually do?
Before you hit me with the obvious, I know, the backup option makes a backup of a file.
But the thing is, the cp command in general backs up a file. One could argue a copy of a file is a backup.
So ...
0
votes
3
answers
151
views
Difference between -q and --quiet? [closed]
I was wondering:
What is the difference between -q and --quiet?
And in which case do I use -q and --quiet?
Thank you!
0
votes
1
answer
519
views
Add options with default value on shell script
I want to add some options to my custom shell script. I can show it to you since it is not top secret content :-P
In my experience, there are two option types, set and unset options: set options are ...
3
votes
1
answer
4k
views
in bash the option "set -e" causes exit immediately, which is a problem in sourced scripts
When using bash in a terminal often scripts have to be run sourced. In such cases terminating the script must be done by "return", but not by "exit" in order to not kill the basic ...
0
votes
1
answer
586
views
When is mandatory use the "--keep-newer-files" option for the tar command?
About the tar command
Introduction
Having for example:
source
numbers
001.txt # with the 111 content
002.txt # with the 222 content
003.txt # with the 333 content
If is created the numbers.tar....
4
votes
1
answer
4k
views
How to extract the tar.gz file but without overwriting existing files?
With the unzip -n /path/to/filename/filename.zip command the compressed file is uncompressed but does not overwrite existing files. This approach is useful when the same compressed file was ...
0
votes
1
answer
2k
views
curl: (6) Could not resolve host: services.gradle.org
If in Ubuntu Server is executed:
curl https://services.gradle.org/distributions/gradle-7.5.1-bin.zip -O
appears:
% Total % Received % Xferd Average Speed Time Time Time Current
...
0
votes
1
answer
1k
views
Llist installed packages with their repository name, version, and architecture using zypper
zypper se -i shows installed packages, but unlike zypper pa the repo, arch, and version information is missing. Is there a command option that shows these bits?
1
vote
1
answer
2k
views
tar create: How to avoid to show the "tar: Removing leading `/' from member names" message in the terminal?
About the tar command
If is executed the command:
tar -czf numbers.tar.gz numbers
The numbers.tar.gz file is created - from the numbers - in the current directory
But for script purposes - by testing ...
0
votes
1
answer
2k
views
Why tar command uses gzip command through 'z' option?
In Linux Ubuntu about the 'tar' command for these versions:
tar -tzf /path/to/filename.tar.gz # Show the content
tar -xzf /path/to/filename.tar.gz # Extract the content
Observe both commands use ...
5
votes
1
answer
3k
views
curl: when use "--no-progress-meter" over "-sS"?
About curl about to hide the Progress Meter I found many answers through Stack Exchange branches doing mention of -s and -S or simply -sS where
-s hides the progress meter
-S only shows error ...
7
votes
1
answer
8k
views
curl: download file with the same name with "-O" but defining a specific path directory
With curl is possible do
curl http://somedomain.com/originalfilename.tar.gz -o newfilename.tar.gz
curl http://somedomain.com/originalfilename.tar.gz -o /other/path/newfilename.tar.gz
Therefore with -...
0
votes
2
answers
204
views
Effect of slash (/) suffixes on symlink names for `ls` with the `-F` option
By way of example, I have a directory structure like this:
$ \ls -F
dir/ lnk@
$ \ls -F dir
FILE
$ \ls -l lnk
lrwxrwxrwx 1 user group d Mon hh:mm lnk -> dir
My ls command is aliased. I am using \...
0
votes
1
answer
340
views
Remove options from command
My inputs are commands followed by an unrestricted number of single-letter options, e.g. command -abc. Neither the command nor the options take any arguments. My goal is to remove certain options.
...
0
votes
1
answer
618
views
How does "-" work in the "ssh-keygen -lf -" command?
I read this question
Get SSH server key fingerprint
In the answer and solution appears the following command (adapted here for presentation purposes)
ssh-keyscan 192.168.1.X | ssh-keygen -lf -
I ...