Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [options]

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

1
vote
1answer
164 views

How do I customize Nautilus / Caja file manager?

I'm using Caja and I miss several features that I had with Windows Explorer. I'm willing to tweak some configs or even develop code to get them but I wouldn't know where to start to collaborate... ...
7
votes
2answers
3k 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 ...
0
votes
1answer
61 views

How do I pass long-style command line options to a bash script using getopt?

I have this script that I have cobbled together from bits of lore I've gleaned from googling: #!/usr/bin/env bash usage() { declare -r script_name=$(basename "$0") echo """ Usage: "${...
-1
votes
1answer
19 views

How can fragment packets -f/--mtu be usefull?

How can fragment packets -f/--mtu be usefull ? That is, say from a normal scan I get for a given IP and port range: 28/tcp filtered unknown no-response 29/tcp filtered msg-icp no-response 30/tcp ...
2
votes
1answer
2k views

What is overriding the fstab permissions mounting option?

fstab: LABEL="Shared" /home/howard/Shared/ ntfs permissions,rw,nosuid,nodev,relatime,uid=howard,gid=howard,allow_other,noatime,fmask=033,dmask=022 0 2 Mount with: mount LABEL="Shared" mount ...
1
vote
1answer
555 views

rsync: How can I pull the --exclude-from file from the remote host?

I'm setting up automated rsync across the network, using (or attempting to use) the following command: rsync -e ssh -avhxAXHr --rsync-path="sudo rsync" --exclude-from=:$EXCLUDEFILE --link-dest=$...
1
vote
1answer
101 views

Can no_console_suspend be set in runtime?

Is it possible to change this value in runtime without rebooting? I don't always have this problem, when I suspend right now I'm getting a failure and Suspending console(s) (use no_console_suspend ...
2
votes
1answer
40 views

su: What does the hyphen with nothing immediately following it mean?

Written as if it were an option, e.g: > su - someuser Don’t the space breaks apart “-“ and “someuser”? I went through the manpage but didn’t notice an entry for it.
1
vote
4answers
21k views

Failed to pass credentials to nfs mount

I am running CentOS 7 and need to mount an NFS share which is protected by credentials. I have read the nfs, mount, mount.nfs manuals and can't find the right options that work! I think the right ...
17
votes
3answers
2k views

Why do options in a quoted variable fail, but work when unquoted?

I read about that I should quote variables in bash, e.g. "$foo" instead of $foo. However, while writing a script, I found an a case where it works without quotes but not with them: wget_options='--...
12
votes
1answer
14k views

Do you need to specify the “defaults” option in fstab?

The Arch Wiki on fstab specifies the options of / to be defaults,noatime, but on my installation the default fstab is created with the options of rw,relatime. The Arch Wiki covers the atime issues. ...
0
votes
1answer
2k views

how to properly parse shell script flags and arguments using getopts

I'm using this : for example ./imgSorter.sh -d directory -f format the scripts' content is : #!/bin/bash while getopts ":d:f:" opt; do case $opt in d) echo "-d was triggered with $...
2
votes
1answer
90 views

Why should I escape the semicolon with find?

I'm using bash on Debian. I have to write find -iname "*mp3" -exec cp {} /media/MP3Player/ \; escaping the final semicolon, or else I get an error.
5
votes
3answers
249 views

Portable way to invoke tar with a list of files from stdin

I want to create a .tgz from the content of a directory. I also want to strip the leading "./" from the tar'ed content. I had done this as follows: cd /path/to/files/ && find . -type f | cut -...
2
votes
0answers
179 views

How to pass options to ssh proxy command?

To collect some data from a bunch of hosts I use a bash script which calls scp in a loop. Most of these hosts are configured for ssh public key authentication. I may skip those which have no key ...
-1
votes
1answer
26 views

Why does adding -prune to my sync script cause rsync to do a DRY-RUN?

I'm testing a script to do a by-directional sync of two directories intelligently using rsync. Since I'm testing many of the rsync options are not applicable to the testing environment including the ...
3
votes
2answers
483 views

Can a bash array be used in place of eval set — “$params”?

I'm taking a look at the optparse library for bash option parsing, specifically this bit in the generated code: params="" while [ $# -ne 0 ]; do param="$1" shift case "$param" in --my-...
3
votes
1answer
386 views

What is “userdel --root?” supposed to do

On a GNU/Linux system, I found the following, (for me very confusing seeming entry) about an option for userdel in the German version of its man page: I'm truly sorry, but I can't really provide you ...
0
votes
1answer
58 views

passing options from an array to built in ls command in UNIX [closed]

I am writing a shell script that takes several args like -l -s -a -f thing ming and append only those starting with -. This is my code: arrayOfArgs=() for arg in "$@": do case arg in -*) ...
3
votes
1answer
2k views

difference between useradd -b and useradd -d

Can somebody please explain to me the exact differences between useradd -b and useradd -d in [Debian] Linux? Both seem to work quite similar to me, but then I spot differences that confuse me.
2
votes
3answers
205 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: ...
9
votes
3answers
10k views

Negative arguments to head / tail

Variants of this question have certainly been asked several times in different places, but I am trying to remove the last M lines from a file without luck. The second most voted answer in this ...
5
votes
1answer
602 views

How to distinguish between a positional parameter and an option?

Both a positional parameter ($1, $2, and so forth) and an option (and/or argument) are both written directly after a command, so what is the definition or phrasing to explain how to distinct them? In ...
1
vote
2answers
5k views

In which case can I use the option '--nodeps' of rpm command?

I heard that I should never use --nodeps option when I do a rpm -e command. Why does this option exist then?
0
votes
2answers
50 views

Are `-name` and `-exec` options or non-option arguments of `find`?

Are -name and -exec options or non-option arguments of find? They look like short options, and they are called find expressions, if I am not mistaken. For example, find . -name "*.txt" -exec echo {} ...
0
votes
2answers
236 views

What are the -i and -o options of wlconf for?

Version = 1.2 # defaults binary_name="/lib/firmware/ti-connectivity/wl18xx-conf.bin" wlconf_path="/usr/sbin/wlconf/" ini_path="/usr/sbin/wlconf/official_inis" {body of code} basically, the user ...
7
votes
3answers
9k 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?
3
votes
2answers
525 views

How to make httpd response 200 for options request?

I want to make some configuration on my centos+apache,let httpd server send 200 response when client make a options request. There is a very old post here(2011). Returning “200 OK” in Apache on ...
2
votes
2answers
4k views

mplayer -msglevel all=-1 doesn't make it completely silent!

I'm trying to open mplayer to play video without any terminal output using this: mplayer -msglevel all=-1 /path/to/video also: mplayer -really-quiet /path/to/video but it doesn't make it ...
30
votes
5answers
34k views

getopt, getopts or manual parsing - what to use when I want to support both short and long options?

Currently I'm writing a Bash script which has the following requirements: it should run on a wide variety of Unix/Linux platforms it should support both short and (GNU) long options I know that ...
20
votes
1answer
1k views

Why does -a in “#!/bin/sh -a” affect sed and “set -a” doesn't?

If I run the following .sh file: #!/bin/sh -a echo "a" | sed -e 's/[\d001-\d008]//g' The result is an error: sed: -e expression #1, char 18: Invalid range end But if I run the following .sh file:...
0
votes
2answers
35 views

Display options for command at the prompt

Is there a way to script any Linux commands to prompt the user for input? For example: chage has many options Options: -d, --lastday LAST_DAY set date of last password change to LAST_DAY ...
-5
votes
2answers
179 views

Signal the end of option arguments: double dashes `--` vs single dash `-`? [duplicate]

I notice in https://unix.stackexchange.com/a/459007/674, that single dash - is used to signal the end of option arguments. Is it correct that double dashes -- can also signal the end of option ...
0
votes
1answer
58 views

Create custom parameters (options) for already existing commands?

Recently I 've been wanting to create a custom parameter for pacman. To elaborate, I have tweaked pacman.conf so that specific packages (linux, linux-firmware, and a couple more) are ignored when I ...
1
vote
0answers
45 views

Bash how does skip-completed-text work?

I use menu-complete bash function to cycle through completion when I press Tab, and I'm happy with it. But it has too often happened to me the following. Suppose I'm looking for the file ...
108
votes
3answers
188k views

How can I execute local script on remote machine and include arguments?

I have written a script that runs fine when executed locally: ./sysMole -time Aug 18 18 The arguments "-time", "Aug", "18", and "18" are successfully passed on to the script. Now, this script is ...
6
votes
3answers
937 views

Set awk array on command line?

I know the -v switch can be used to awk on the command line to set the value for a variable. Is there any way to set values for awk associative array elements on the command line? Something like: ...
3
votes
2answers
736 views

Xargs `-J` Option

This site presents the xargs command with a -J option making able to pass the standard input into a desired position at the command argument: find . -name '*.ext' -print0 | xargs -J % -0 rsync -aP % ...
0
votes
1answer
406 views

What is — and -td options on ls command?

Could you please explain what each option on this ls command does: ls -td -- */? The result of such command would look like below: $ ls $ ls -al total 4 drwxr-xr-x 5 root root 68 Jun 4 09:58 . ...
7
votes
3answers
7k views

What is a “non-option argument”?

I am trying to understand info who but completly fail at the term »non-option argument«. Can someone please explain this term to me in simple words or an example? UPDATE: from ' info who' ...
6
votes
3answers
12k views

Optional arguments after or before the mandatory arguments?

I'm creating a shell script and I need it to take two mandatory arguments and one optional. How do I check that? In most scripts I've seen, the optional arguments are passed before the mandatory ones, ...
-1
votes
1answer
85 views

How shall we understand “if no arguments remain after option processing”?

Basy manual says that for the command bash: -s If this option is present, or if no arguments remain after option processing, then commands are read from the standard input. This option ...
326
votes
10answers
132k 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 ...
0
votes
1answer
24 views

How to search based on a $OPTARG that I provided in a file?

I am trying to make an executable file for search a specific text. I want to retrieve any line in my data file that include the value that I pass it. So I create a data file called .addr_book and I ...
1
vote
2answers
38 views

The alternative to Option '--update' in BSD command 'mv'

I am reading a book "Linux Command Line", there's -u update option for command mv and `cp' -u, --update When moving files from one directory to another, only move files that either don't exist, ...
0
votes
3answers
260 views

parsing a command option in a bash script

I wrote I ‘quick’ script, and then thought of adding a “—nomail” option that would shut off my mail switch (of which the syntax is piped in from echo). I thought this would be easy but I think, ...
1
vote
1answer
669 views

Parameters of find command

What difference does it make when using the -print and -depth parameters in find command, given that they produce the same outcome: /home/pkaramol/Desktop/testdir $ find . . ./testfile3.txt ./...
0
votes
1answer
62 views

How to protect potentially destructive command line options?

I'm curious if anyone can help me with what the best way to protect potentially destructive command line options is for a linux command line application? To give a very hypothetical scenario: imagine ...
0
votes
1answer
142 views

Ask for detail explanation on sort utility option

I tried to use sort utility and typed sort --help, read one of lines saying its -k option, and part of it: OPTS is one or more single-letter ordering options [bdfgiMhnRrV], which override global ...
0
votes
1answer
40 views

Make all files in a dir executable (non-recursively) while strictly-ensuring non-recursivness

I grasp the heading of this question odd, but I do wonder if in some situations there should be a need to take extra caution and somehow "enforce" non-recursivness when changing permissions with chmod ...