Questions tagged [options]
Passing options like -l or --word to commands, or parsing them in scripts.
338
questions
2
votes
4
answers
1k
views
'rename' with expression|replacement with a leading '-' (hyphen|minus)
I have many files like xyz_123_foo.ext for which I would like to add -bar to the filenames at the end to result in xyz_123_foo-bar.ext. I tried:
rename . -bar. xyz_*
which resulted in:
rename: ...
1
vote
0
answers
523
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, ...
5
votes
1
answer
526
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 ...
0
votes
1
answer
293
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 ...
2
votes
2
answers
83
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 ...
55
votes
4
answers
43k
views
tree command for multiple includes and excludes
Could you please give me an example of using the tree command to filter out result as follows:
to ignore directories (say bin, unitTest)
only listing certain files having extensions (say .cpp, .c, ....
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 ...
12
votes
2
answers
1k
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?
0
votes
1
answer
70
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
0
votes
1
answer
615
views
ERROR: Unrecognized option: --host_jvm_args=-Xmx4g
OS: Linux
Distrib: Debian GNU/Linux 10 (buster)
bazel: v3.1.0
I try to get the memory limit to 4GB for bazel, but I get the error:
ERROR: Unrecognized option: --host_jvm_args=-Xmx4g
The whole ...
-4
votes
1
answer
352
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 ...
0
votes
1
answer
582
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 ...
0
votes
1
answer
87
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 ...
5
votes
2
answers
705
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 ...
6
votes
1
answer
2k
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 ...
63
votes
4
answers
11k
views
Where is the `--` (double dash) argument documented?
There are some utilities that accept a -- (double dash) as the signal for "end of options", required when a file name starts with a dash:
$ echo "Hello World!" >-file
$ cat -- -file
Hello World!
...
7
votes
1
answer
898
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, ...
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) ...
1
vote
1
answer
51
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 ...
3
votes
1
answer
1k
views
ps: error: conflicting format options
$ ps -l -o ruid,euid,rgid,egid,sess -p $$
error: conflicting format options
Usage:
ps [options]
Try 'ps --help <simple|list|output|threads|misc|all>'
or 'ps --help <s|l|o|t|m|a>'
...
1
vote
1
answer
3k
views
ps: output modifiers vs output format control
In the manpage of ps
-j Jobs format.
-f Do full-format listing.
-o format
User-defined format.
$ ps -j -o ppid,sid
error: can not use output modifiers with user-defined output
$ ps -f -o ...
0
votes
0
answers
34
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 ...
4
votes
1
answer
3k
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 ...
0
votes
0
answers
612
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)
...
0
votes
1
answer
537
views
ps command: How generate the report of processes but according with only either tty or pts?
Through the ps --help all command about the option(s) related with tty exists the following:
-a all with tty, except session leaders
a all with tty, including ...
4
votes
2
answers
426
views
What does '-P' mean in the context of the 'ps' command?
If is executed ps -p 3384 3395 (observe -p is lowercase) then the output is as follows:
PID TTY STAT TIME COMMAND
3384 tty6 S+ 0:00 man ls
3395 tty6 S+ 0:00 pager
Until ...
13
votes
3
answers
20k
views
What does the option -9 mean for killall?
I saw the command killall -9 but there is not such a option in the man page.
So now I'm a bit confused: what does -9 option mean?
9
votes
3
answers
14k
views
Remove many many many files from a folder
I have a folder with 137795 files in it. I need to delete all of them. When I run rm * I get -bash: /bin/rm: Argument list too long. How do I get past this error?
-2
votes
2
answers
2k
views
Command du -xh / | grep -P "G\t" explained?
I came across the command
du -xh / | grep -P "G\t"
I am interested in the switch -P of grep and what does it do. Also, can anyone explain what the "G\t" part does?
Please do not ...
1
vote
1
answer
7k
views
What does the "+x" option in "bash +x script.sh" mean?
I know what bash -x does, but what does bash +x do?
Googling found no results and the manual also says nothing about it.
0
votes
1
answer
92
views
Why does the option --add_extra_groups in adduser contain underscore rather than hyphen word delimiters?
Premise
Most of the long-form options in the various *nix tools use hyphens as word separators.
Examples
from man tr:
--squeeze-repeats
--truncate-set1
from man sudo:
--preserve-env
--set-home
--...
44
votes
2
answers
64k
views
What's the difference between a flag, an option, and an argument? [closed]
ls -a (I consider -a an option)
sudo -u username (-u = option, username = arg)
chmod 664 my-dir (664 = option, my-dir = arg)
I can't think of an example that might say "this is a flag" ...
1
vote
2
answers
504
views
autoconf tried to invoke "exec -m' under bash, but -m is not a legal operand for exec
This question may really be about where to get help, rather than help for the problem itself. Please forgive the wordiness!
I'm trying to build gcc to run on Win32 and produce code for AVR. I've ...
1
vote
1
answer
1k
views
Invoke a program in a Bash script with command line parameters stored in a variable
Is it possible to invoke some program in a Bash script with complete command line parameters (both the key and the value) stored in variables?
I use the following scanimage call in a script:
scanimage ...
8
votes
5
answers
6k
views
grep getting confused by filenames with dashes
I'm having a problem where grep gets confused when the directory contains a file starting with dashes.
For example, I have a file named "------.js" . When I do something like grep somestring * I get ...
34
votes
2
answers
8k
views
Do command line options take an equals sign between option name and value?
Just using kubectl as an example, I note that
kubectl run --image nginx ...
and
kubectl run --image=nginx ...
both work.
For command-line programs in general, is there a rule about whether an equals ...
3
votes
3
answers
1k
views
find -exec command options with basename [duplicate]
I have the following JPEG files :
$ ls -l
-rw-r--r-- 1 user group 384065 janv. 21 12:10 CamScanner 01-10-2022 14.54.jpg
-rw-r--r-- 1 user group 200892 janv. 10 14:55 CamScanner 01-10-2022 14.55.jpg
-...
1
vote
1
answer
1k
views
How to get option value $OPTARG correctly?
I would like to get an option value when launching a shcell. I wrote:
optstring=hcnxl:
V=0
while getopts $optstring opt; do
case $opt in
h) V=1 ;;
c) V=2 ;;
n) V=3 ;;
x) V=4 ;;
...
-1
votes
1
answer
71
views
"$-" Returns 569X During ZSH Invocation [duplicate]
Background
While studying the shell parameter, $-, for sh, bash, and zsh, I discovered that it returned current option flags, hBc, for both sh and bash but 569X for zsh.
SUSE >> bash -c 'echo &...
-2
votes
1
answer
73
views
What does pr -m -t means?
What does pr -m -t mean? I managed to find out that -t suppresses headers and footers. What does -m mean specifically?
-1
votes
1
answer
48
views
Parsing `-C8` to get value to option -C
I want to parse -C8 to a bash function and get the numeric value in a variable.
I have seen argument parsing implementations for -C 8 and -C=8, but not for -C8.
while (( $# > 0 )); do
case $1 ...
1
vote
2
answers
76
views
What is the reasoning behind accepting truncated long command line options?
Many command line utilities accept long ("GNU style", according to [1]) options such as --version. To my surprise, truncated versions are often interpreted as the full option. For example, ...
0
votes
2
answers
130
views
Exit while loop when reaching last positional argument
I want to adapt this so that when the function reaches the last positional argument, the while condition exits.
console_codes ()
{
local exec=0
local narg="$#" iarg=0
while (( narg > 0 ...
493
votes
10
answers
210k
views
How do I delete a file whose name begins with "-" (hyphen a.k.a. dash or minus)?
How do you remove a file whose filename begins with a dash (hyphen or minus) -? I'm ssh'd into a remote OSX server and I have this file in my directory:
tohru:~ $ ls -l
total 8
-rw-r--r-- 1 me ...
2
votes
1
answer
65
views
Dealing with simple help option far bash function
I have adapted some code I had to handle just a single possible option. Either run the function or use the help option to give a brief description.
activate-jet ()
{
local iarg=0 narg="$#&...
0
votes
1
answer
1k
views
getopt optional argument with optional value
I am using getopt and want to have an option -l that takes an optional value. I am finding that when matching -l by itself with no argument value provided, I still have to use shift 2 rather than
...
10
votes
2
answers
9k
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 ...
4
votes
3
answers
908
views
Looping through command line parameter options until next parameter
In a new addition to a script I am working on, I want to loop through parameters associated with a flag until zsh reaches the next flag in the command. For instance, when the user enters the following:...
-1
votes
1
answer
161
views
ls -l | cut -c1-11,50- Can Someone Explain the 2nd part after the pipe?
I have taken a course in that suddenly I saw this, I understood until the pipe but the options used after the pipe for the command cut are bit confusing
-1
votes
1
answer
72
views
Is it OK if I add a duplicated option when calling an alias for rm?
I have alias rm='rm -i' in .bashrc.
Now, if I use rm -i by mistake, it will become rm -i -i.
Would anything go wrong because of two same options?