Skip to main content

Questions tagged [options]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
42 views

what is a "flag" in bash? and how is it different then other options? what would be a good example to highlight the difference? [duplicate]

so i keep hearing that a flag is a TYPE of option, and that the only difference between a flag and normal options is that a flag is a type of "boolean" option, which when explained to me ...
how to bash's user avatar
0 votes
1 answer
139 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 "...
Harald's user avatar
  • 958
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 ...
Kamil Maciorowski's user avatar
0 votes
0 answers
51 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 ...
typo's user avatar
  • 239
0 votes
1 answer
53 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 "--...
Nor.Z's user avatar
  • 133
1 vote
1 answer
256 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 ...
Byron Hawkins's user avatar
1 vote
1 answer
89 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 ...
Husky2490's user avatar
0 votes
1 answer
98 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-...
Maksim Aleksanin's user avatar
8 votes
1 answer
1k 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 ...
kjo's user avatar
  • 16k
6 votes
1 answer
191 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 ...
student's user avatar
  • 18.7k
0 votes
3 answers
489 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. ...
VintageDroid's user avatar
-1 votes
1 answer
441 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 ...
Vlastimil Burián's user avatar
-1 votes
1 answer
61 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 ...
user avatar
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 ...
user67275's user avatar
  • 243
0 votes
2 answers
407 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>&...
user avatar
1 vote
1 answer
102 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 ...
not2savvy's user avatar
  • 273
4 votes
2 answers
5k 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 ...
backslash enn's user avatar
0 votes
3 answers
182 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!
Vroni Jane's user avatar
0 votes
1 answer
761 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 ...
Bruno Peixoto's user avatar
3 votes
1 answer
5k 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 ...
Anton Wessel's user avatar
0 votes
1 answer
779 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....
Manuel Jordan's user avatar
5 votes
1 answer
5k 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 ...
Manuel Jordan's user avatar
0 votes
1 answer
3k 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 ...
Manuel Jordan's user avatar
0 votes
1 answer
2k 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?
user547462's user avatar
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 ...
Manuel Jordan's user avatar
0 votes
1 answer
3k 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 ...
Manuel Jordan's user avatar
6 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 ...
Manuel Jordan's user avatar
7 votes
1 answer
9k 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 -...
Manuel Jordan's user avatar
0 votes
2 answers
243 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 \...
Ana Nimbus's user avatar
0 votes
1 answer
372 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. ...
rewire's user avatar
  • 111
0 votes
1 answer
766 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 ...
Manuel Jordan's user avatar
0 votes
1 answer
508 views

getopt and case function not executing

I encountered such a problem when passing a parameter to a script, the function corresponding to the case menu is not executed. The script accepts parameters as input and performs the appropriate ...
Maverick's user avatar
1 vote
0 answers
656 views

/etc/fstab mount option restrictions - How to get full options list applied?

This question is a related but tangent question on problem described in this posting . While trying to finalize the options during the previous post, I always left the root partition alone, untouched, ...
Eric Marceau's user avatar
0 votes
1 answer
339 views

EXT4 on USB - how to specify journalling behaviour to be same as for root disk partitions

Please consider the prior discussion as background to this new question. I have modified my script and applied the same filesystem options to my USB drive's ext4 partitions using tune2fs, and mount ...
Eric Marceau's user avatar
5 votes
1 answer
664 views

OS seems to apply ext4 filesystem options in arbitrary fashion

I fear I may have to revert to system defaults if I can't get this sorted out. I'm trying to set various system configurations for more robust ext4 for a single-user desktop environment. Trying to ...
Eric Marceau's user avatar
3 votes
3 answers
2k views

Replacing command line arguments while preserving spaces

I would like to selectively replace a command-line argument that is being passed to automatically format it for the downstream command being executed. The argument will have spaces and that is the ...
Walter's user avatar
  • 1,244
12 votes
2 answers
2k views

Why does sort have an --output= option?

sort -o seems superfluous. What is the point of using it when we can use sort >? Is it sometimes impossible to use shell redirection?
EmmaV's user avatar
  • 4,107
2 votes
2 answers
92 views

Why is `-W` reserved for vendor extensions?

Why does the POSIX standard reserve the -W option for vendor extensions of the system utilities? I do not understand why the letter ‘W’ is used. ‘V’ (for vendor) could make more sense. Maybe this ...
jiwopene's user avatar
  • 1,081
0 votes
1 answer
147 views

What does '-' mean in a Shell script?

I'm trying to understand a script I have and it has a line that says cut -d '-' -f 1 I don't understand what '-' does here
zwz's user avatar
  • 11
-4 votes
1 answer
477 views

ps command: how does the '-q' option work?

According with the ps command, for the -q option Through the man is indicated: -q pidlist Select by PID (quick mode). This selects the processes whose process ID numbers appear in ...
Manuel Jordan's user avatar
0 votes
1 answer
801 views

ps command: how show the complete command with options, pipes and redirection? (or all together)

About the ps command, consider if for simplicity: in tty3 is executed the yes command in tty4 is executed the yes > /dev/null command through ps I need to show in the report the complete command ...
Manuel Jordan's user avatar
-1 votes
1 answer
743 views

ps command: how does the 'r' option work? How should be used?

About the ps command for the r option According with man ps it indicates r Restrict the selection to only running processes. And according with ps --help a it indicates r only ...
Manuel Jordan's user avatar
0 votes
1 answer
101 views

less command: b/f vs w/s

About the less and according with: Less command Linux / Unix Colored Man Pages With less Command indicates the following: f ^F ^V SPACE * Forward one window (or N lines). b ^B ESC-v * Backward ...
Manuel Jordan's user avatar
5 votes
2 answers
992 views

less command g vs p option

In less for navigation purposes according with this tutorial Less Command in Linux indicates: g Go to the first line in the file. p Go to the beginning of the file. I tested both, and of course ...
Manuel Jordan's user avatar
7 votes
1 answer
1k views

What is correct or suggested approach to send the signal name through 'kill' command?

I read many tutorials about the use of kill command, mostly 3 approaches kill -15 <pid> kill -SIGTERM <pid> kill -TERM <pid> For scripts purposes and for portability with macos too, ...
Manuel Jordan's user avatar
4 votes
3 answers
2k views

Why are the signal lists for kill, killall and pkill not the same?

I researched the kill, pkill and killall commands, and I understood most of their differences. However, I am confused about their signals: If I run kill -l, I see: 1) SIGHUP 2) SIGINT 3) ...
Manuel Jordan's user avatar
0 votes
0 answers
39 views

ps command: Practical difference between the -p and -q options [duplicate]

According with man ps exists: -p pidlist Select by PID. This selects the processes whose process ID numbers appear in pidlist. Identical to p and --pid. -q pidlist Select by PID ...
Manuel Jordan's user avatar
1 vote
1 answer
80 views

ps command: strange behavior with 'O' option, extra column/header does not appear as expected

About the ps command - to add one/many extra column/header with the default headers according with the option(s) used with the ps command - it through O the option. Intro If ps x is executed the ...
Manuel Jordan's user avatar
4 votes
1 answer
4k views

ps command: how to know all the headers with their respective descriptions?

Through the following valuable tutorial: Ps Command in Linux (List Processes) If the ps -ef command is executed then the output has the following header: UID PID PPID C STIME TTY ...
Manuel Jordan's user avatar
0 votes
0 answers
832 views

What does '-x' mean in the context of the 'ps' command?

If is executed ps x (observe there is no -) then the output is as follows: PID TTY STAT TIME COMMAND 2489 ? Ss 0:00 /lib/systemd/systemd --user 2490 ? S 0:00 (sd-pam) ...
Manuel Jordan's user avatar

1
2 3 4 5
7