Questions tagged [options]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
43 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 ...
user avatar
  • 800
0 votes
1 answer
48 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
user avatar
  • 11
-4 votes
1 answer
39 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 ...
user avatar
0 votes
1 answer
31 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 ...
user avatar
0 votes
1 answer
55 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 ...
user avatar
0 votes
1 answer
39 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 ...
user avatar
5 votes
2 answers
451 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 ...
user avatar
6 votes
1 answer
515 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, ...
user avatar
4 votes
3 answers
1k 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) ...
user avatar
0 votes
0 answers
24 views

jobs command: How report all the done/finished processes, but at anytime?

About background processes, for simplicity if for example are executed: sleep 300 & sleep 350 & sleep 360 & sleep 400 & sleep 800 & When is executed jobs -l, in the output is ...
user avatar
0 votes
0 answers
33 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 ...
user avatar
1 vote
1 answer
30 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 ...
user avatar
3 votes
1 answer
128 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 ...
user avatar
0 votes
0 answers
41 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) ...
user avatar
0 votes
0 answers
31 views

ps command: what does "/bin/login -p --" exactly mean? What is its purpose to be shown?

Through Virtual Box for Ubuntu Server, having: the 6 tty being logged with 3 different users (2 users in 2 tty, for example user1 logged at tty1 and tty3, user2 logged at tty2 and tty4 and so on) 3 ...
user avatar
0 votes
1 answer
52 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 ...
user avatar
4 votes
2 answers
158 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 ...
user avatar
0 votes
1 answer
254 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.
user avatar
0 votes
1 answer
30 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 --...
user avatar
0 votes
1 answer
79 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 ...
user avatar
  • 394
1 vote
1 answer
71 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....
user avatar
  • 113
1 vote
1 answer
63 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 ...
user avatar
3 votes
3 answers
286 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 -...
user avatar
  • 1,032
1 vote
1 answer
205 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 ;; ...
user avatar
  • 315
-2 votes
1 answer
39 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?
user avatar
  • 55
-1 votes
1 answer
33 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 &...
user avatar
-1 votes
1 answer
34 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 ...
user avatar
0 votes
2 answers
56 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, ...
user avatar
  • 109
0 votes
0 answers
145 views

Alternatives to getopts for referencing flag next to argument

So I'm currently writing a script that takes arguments next to options to assigns them to variables. From the command line it'd look something like this >> ./myscript.sh --gpu 2 --cpu 12 --mem ...
user avatar
  • 187
0 votes
2 answers
49 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 ...
user avatar
  • 53
2 votes
1 answer
42 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="$#&...
user avatar
  • 53
0 votes
0 answers
28 views

Find size of newest Borg archive in a single step

I can find information about the size of the newest archive in a Borg repository in two steps: use list to display the names of all the archives; manually select the name of the newest one from the ...
user avatar
0 votes
1 answer
145 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 ...
user avatar
  • 155
4 votes
3 answers
457 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:...
user avatar
  • 53
-1 votes
1 answer
42 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
user avatar
-3 votes
1 answer
70 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?
user avatar
0 votes
3 answers
2k views

Can you make a bash script's option arguments be optional?

I would like either of these inputs to work. That is, the -n option itself is optional – I already know how to do that – but it then may have an optional parameter on top. If no parameter is given, a ...
user avatar
0 votes
0 answers
81 views

difference between environment variables and parsing command line options?

Am I wrong in assuming that both environment variables serve similar purposes - to modify default behaviour of a program from the shell? When writing a program in C, for example, if I am faced with ...
user avatar
0 votes
1 answer
72 views

Setting verbosity level from list of function arguments

I am using a bash function to which I pass arguments. I would like to capture if a particular option was defined by the user -v NUM or --verbosity=NUM. If defined as described, I would like to set ...
user avatar
  • 59
2 votes
4 answers
812 views

When are grouped parentheses for multiple options necessary?

I am using the find and grep commands. Getting quite confused about when multiple options are joined by "or" with the -o flag and the use of grouped parentheses, and when grouped parentheses ...
user avatar
  • 319
0 votes
0 answers
45 views

Removing delimiters from bash array elements, then transferring result to another array

I am using an option variable array incl that stores filename extensions. ("--incl") local incl+=("$2") ; shift 2 ;; The function can then be called using --incl .texi --...
user avatar
  • 319
0 votes
0 answers
100 views

Handling Optional Arguments in bash

I have the following function that is supposed to write strings in new lines. There is a warning option, so that when -w is set by the user, some lines get coloured in red. -w allows an optional ...
user avatar
  • 319
0 votes
1 answer
581 views

options with optional values using getopt

I have the following function and would like to look into how options with optional values can be set up using getopt. Would like to have -w taking on default values region -w -- "Text" And ...
user avatar
  • 319
0 votes
1 answer
39 views

Adding options using bash arrays

I am using a bash script to call rsync commands. Have decided to collect some options in an array called oser. The idea is to look at what's different in the two invocations and put that into the ...
user avatar
  • 319
-1 votes
1 answer
183 views

Bash function with dry-run and exec options [closed]

Am writing a bash function to run rsync, with possibility of using --dry-run option and --exec option. Need some criticism improvements and additional checks. Might not make much sense for the user ...
user avatar
  • 319
2 votes
2 answers
579 views

How to grep for a pattern that looks like an option? [duplicate]

m@m-VirtualBox:~$ man netstat | grep "-t" grep: invalid option -- 't' Usage: grep [OPTION]... PATTERNS [FILE]... Try 'grep --help' for more information. I don't want to pass the -t option ...
user avatar
  • 1,270
1 vote
1 answer
119 views

Passing arguments to a command safely

It is well known that it's a bad idea to do something of the kind <command> $FILENAME, since you can have a file whose name is for example -<option> and then instead of executing <...
user avatar
0 votes
1 answer
22 views

What are really the prefix rules for options: - and -- ? Why is the find command not compatible with the --name option? [duplicate]

Once, I've learned that options of Linux commands came in two manners: those of one letter, prefixed by a - those of many letters, prefixed by a -- And this works in 95% of the cases. But not, for ...
user avatar
  • 757
-1 votes
1 answer
343 views

last: invalid option -- 's'

I learned from several posts that we can use the -s (since) option to show login events that took place since a specific date. However, it encountered the error invalid option. root@VM-0-6-centos ~ $ ...
user avatar
4 votes
2 answers
739 views

Difference between 'sed -e' and delimiting multiple commands with semicolon

I am perhaps picking nits here, but it would be really good to have this question that's been bothering me answered once and for all... Text file for reprex: Line one. Line two. Line three. Line four....
user avatar

1
2 3 4 5 6