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
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 ...
0
votes
1answer
63 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: "${...
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
1answer
169 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... ...
2
votes
1answer
91 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
251 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
185 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 ...
2
votes
3answers
211 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: ...
5
votes
1answer
605 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
1answer
110 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 ...
0
votes
2answers
51 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 {} ...
3
votes
2answers
537 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 ...
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
185 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
46 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 ...
0
votes
1answer
410 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 . ...
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 $...
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 -*) ...
-1
votes
1answer
87 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 ...
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
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 ...
0
votes
3answers
264 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
677 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
66 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
143 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 ...
2
votes
1answer
2k views

Nmap unable to resolve flags

When I type in the command nmap –Pn –sT -sV –p0-65535 192.168.1.100, my terminal responds: Starting Nmap 7.60 ( https://nmap.org ) at 2018-01-29 11:24 PST Failed to resolve "–Pn". Failed to resolve "–...
2
votes
1answer
394 views

What are the differences between command options and switches?

From Java in a Nutshell: The syntax of the jar command is intentionally very similar to that of the Unix tar command. This similarity is the reason why jar uses command options, rather ...
-1
votes
1answer
178 views

Human-readable `du` with finer grain

I sometimes wish human-readable du -h option to be more fine-grained while still human-readable. Instead of showing: 14G it would show something like: 14G 236M 788k 110b Is there an easy / ...
3
votes
2answers
744 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 % ...
3
votes
2answers
410 views

Should I use mutually exclusive options on my command line tool?

Writing a CLI tool, I'm facing a conundrum. The tool is supposed to detect faces in images and blur them automatically. However, sometimes only one of those things should be done to allow marking ...
0
votes
2answers
352 views

How to pass every line of a file as options to a command?

I'd like to write a script that reads a file and passes every line as options (or "option arguments") to a command, like this: command -o "1st line" -o "2nd line" ... -o "last line" args What's the ...
0
votes
1answer
417 views

How to use the man command to navigate to specific sections of the manual? [duplicate]

I would like to know if there are easier ways to navigate to specific sections of manual pages such as Examples or Options I currently resort to piping man to regex find and retrieve statements. For ...
0
votes
1answer
797 views

rsync: Why doesn't --archive imply --recursive when --files-from=FILE is used?

Using -r or --recursive causes rsync to recurse into directories. -a or --archive equals -rlptgoD, so -a implies -r. If I have directories source/ and dest/ and I run: rsync source dest then rsync ...
58
votes
1answer
3k views

What is the actual purpose of GNU grep's -X option and why is it undocumented?

By reading this question, I have discovered that GNU grep has a -X option which expects an argument. Strangely, it is mentioned neither in the man page nor in the info page. Looking at the source ...
2
votes
1answer
113 views

is each CLI command option an semantic abbreviation [closed]

The key is about semantics. curl -I, which means curl --head, puzzled me. I don't know what the semantic words the alphabet I stand for? Is it just a reference rather than an abbreviation of a ...
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='--...
0
votes
1answer
69 views

Can a long option be shortened arbitrarily?

Is that a long option can be shortened arbitrarily part of GNU conventions for options, or some other conventions/standards, or just provided by some special C function? For example, why do python ...
3
votes
1answer
512 views

Meaning of the double dash in options [closed]

I've read that all multi-character command options must be preceded by a double dash (--). But many flags for the find command (e.g. -name or -type) are preceded by only one dash. Why is that?
4
votes
2answers
111 views

Bug or Feature? Grep accepts files as flags

I just ran into a weird scenario, and I'm not sure if this is a feature, and if not, what sort of security implications does it represent? Likely nothing for grep, but other directory-crawling ...
0
votes
1answer
29 views

Does the params and the name affect the command in Linux?

I see the tutorial, when create a user: useradd -g liao1 lamp You see they place the -g liao1 before the lamp, and I tested the: useradd lamp -g liao1 I put the param after the name, I can create ...
3
votes
4answers
2k 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 ...
0
votes
1answer
744 views

Bash get input while flag present?

I'm writing a bash script that has optional flags but also an input. I can't get the input as $1 because when flags are present the input is shifted. So for example if I run script.sh test then $1 ...
0
votes
2answers
573 views

Can't use echo option within shell script file

My sh is bash. I need a percentile progress indicator for my 0~9999 'for' loop... So I use this lines within the loop, but the output is very strange. #!/bin/bash declare -i percentile for((i=0;i<=...
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 ...
0
votes
2answers
1k views

How to determine the options Linux kernel was build with? [duplicate]

Say, I have custom kernel from my distribution, how could I get list of all options the kernel was build with? It's possible to get them by reading config file from kernel package from vendor's repo, ...
1
vote
1answer
285 views

joe (editor) global vs. local options on the command line?

joe (Joe's Own Editor) manual outlines the command syntax like so: joe [global-options] [ [local-options] filename ]... My question is, how do I demarcate global-options from local-options? An ...