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

learn more… | top users | synonyms

4
votes
2answers
70 views

When compiling, can I use a file for ./configure options?

Building some software from source and there are a lot of configure switches. ./configure --enable-ftp --with-gettext ... I have all the switches I want in a text file separated by new lines, e.g.:...
6
votes
2answers
1k views

What does ls -alh mean? [duplicate]

I have seen that people use ls -alh in the Linux terminal. However, when I see the manual, I don't see -alh (i.e. when I type man ls). Why do I not have it in the manual? Can someone explain what it ...
20
votes
4answers
4k views

Is there a 'rc' configuration file for grep/egrep? (~/.egreprc?)

I usually do some grep when developing, and there are some extensions that I always don't want to look for (like *.pyc). Is it possible to create a ~/.egreprc or something like that, and put some ...
11
votes
2answers
358 views

Why can spaces between options and parameters be omitted?

For example: xargs -n 1 is the same as xargs -n1 But if you look at the man page, the option is listed as -n max-args, which means the space is supposed to be preserved. There is nothing about ...
5
votes
1answer
53 views

Why did “argument can be squished against option” prevail over “argument is always separate”?

Inspired by the recent question Why does the specific sequence of options matter for tar command?, in which the asker learned why tar -cfv test.tar *.jpg doesn't work, I'd like to ask a followup: ...
3
votes
1answer
58 views

Abbreviated long options on the command line of xclip

In the manpage of xclip -selection specify which X selection to use, options are "primary" to use XA_PRIMARY (default), "secondary" for XA_SECONDARY or "clipboard" for XA_CLIPBOARD Note that ...
0
votes
1answer
37 views

Use of Verbose in a cron job

I'm busy setting up a back-up script to run on my Pi using rsync. I see that a number of people use the -v option in their cron jobs. Why? It's going to be run as root, and not in a terminal where ...
6
votes
3answers
23k views

How can I detect that no options were passed with getopts?

I have this code - #getoptDemo.sh usage() { echo "usage: <command> options:<w|l|h>" } while getopts wlh: option do case $option in (w) name='1';; ...
0
votes
2answers
110 views

What's the difference between a flag, an option, and an argument? [closed]

Examples: 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" ...
4
votes
1answer
159 views

If I'm logged in as root, how do I restart mysql or apache with options?

I know the commands to restart/stop/start, but when I try to pass options it doesn't seem to work! CENTOS 6, MySQL 5.14 service mysql restart service httpd restart Then I tried this: /etc/init.d/...
0
votes
1answer
54 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 ...
1
vote
4answers
65 views

Why is it find dir -name file and not find -n dir file?

I've searched around for this but I couldn't find anything on it. I've always wanted to know, why is it that most other built in bash commands have the format of command -flag arg1 arg2, i.e. cp -r ...
-3
votes
2answers
34 views

What does the -p option do in the read command?

What does the -p option do in the read command? An example: read -p "Please enter your first name: " firstName An explanation of the -p option on read's manual page (I don't understand this): ...
0
votes
1answer
47 views

Why do i need -d option on this cut command?

I have one txt file called sales.txt Fred apples 20 April 4 Susy oranges 5 April 7 Mark watermelons 12 April 10 Terry peaches 7 April 15 And when i use this command: [root@ip-10-0-7-125 bash-tut]#...
30
votes
6answers
9k views

Single dashes `-` for single-character options, but double dashes `--` for words?

Where did the convention of using single dashes for letters and doubles dashes for words come from and why is continued to be used? For example if I type in ls --help, you see: -a, --all ...
3
votes
2answers
9k views

List of available command options?

I'm currently setting up my first web server without a control panel and so far things are going pretty good! I was just wondering if anyone could direct me to somewhere that explains all of the ...
2
votes
1answer
51 views

Why is the xargs -i option deprecated?

I was reading the Linux man page for xargs recently, and it appears that the -i option is deprecated. To quote from the documentation: -i[replace-str], --replace[=replace-str] This ...
0
votes
2answers
107 views

Explanation of options(flags) for bash [closed]

I often see scripts with usage of options as in if [ -f some_file ] checks whether some_file is a file. I have a very vague understandings of flags, but can someone give me a good explanation? Others ...
1
vote
2answers
73 views

How to order several options of a command (ls)?

Why doesn't ls behave the same after exchanging the order of options -l and -f? $ ls -l -f 0821131236.jpg 0823130821.jpg $ ls -f -l total 33176 -rw-rw-r-- 1 t t 364186 Jan 6 16:06 ...
1
vote
2answers
28 views

Should the operands to a utility always appear after all the options to the utility?

POSIX says utility_name[-a][-b][-c option_argument] [-d|-e][-f[option_argument]][operand...] ... The arguments following the last options and option-arguments are named "operands". ...
0
votes
1answer
63 views

NFS server mount options vs. client mount options

On an NFS server, the shares are typically set up in /etc/export, where mount options like rw, root_squash, sync etc. can be set. When mounting the NFS share on the client side, again mount options ...
6
votes
2answers
9k views

syntax of ls --hide= and ls --ignore=

ls --hide and ls --ignore provides the possibility leave out files defined through regular expressions set after the --ignore= part. The latter makes sure that this option isn't turned off via -a, -A. ...
3
votes
2answers
156 views

The discrimination between short and long option is only `-`?

On Unix system, options begin with - is short option, while options begin with -- is long option. Is my understanding right?
3
votes
2answers
383 views

How does the -d option to bash read work?

I have a bash script where I'm trying to assign a heredoc string to a variable using read, and it only works if I use read with the -d '' option, i.e. read -d '' <variable> script block #!/...
-2
votes
1answer
104 views

What does the -p option do exactly with the cp command?

So I am trying to understand what is the significance of the -p option for the cp command. I opened the manual of the cp command and it says -p same as --preserve=mode,ownership,time stamps. But ...
3
votes
2answers
76 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: ...
2
votes
3answers
166 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?
1
vote
1answer
88 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-...
1
vote
2answers
37 views

Listing negative numbers in zenity --list

$ zenity --list --column 'Numbers' '-3' This option is not available. Please see --help for all possible usages. $ zenity --list --column 'Numbers' -- '-3' So obviously zenity is interpreting the ...
38
votes
7answers
7k views

why does ls -d also list files, and where is it documented?

when specifying ls --directory a* it should list only directories starting with a* BUT it lists files AND directories starting with a Questions: where might I find some documentation on this, ...
5
votes
1answer
7k views

Provide two arguments to one option using getopts

In below code when I give option r then getopts requires one arguments: while getopts ":hr::l:" opt; do case $opt in r ) echo "Run Numbers - argument = $OPTARG " ;; l ) echo "...
5
votes
1answer
99 views

Why do some utilities parse operands before options?

According to several sources, the UNIX utility guidelines specify that operands should always be processed after options: utility_name[OPTIONS][operands...] Some older UNIX utilities are known to ...
0
votes
3answers
62 views

Understanding options to sort

part 1 ps -e | sort -k 1 -nr What is the interpretation of the above command? I want to understand the role of -nr. It is not clearly given the man pages of sort. part 2 When you open the man ...
3
votes
1answer
81 views

Is there a way for “less” to truncate lines and still exit after < 1 screen?

Like many (most), I use git, which by default sends its output (for diffs, logs, etc.) to less, with the options -FRSX. The options are overrideable in .gitconfig by setting the pager to be called ...
0
votes
1answer
76 views

Is a “--silent” flag supposed to suppress warnings and errors, or just warnings?

I'm designing a terminal-based application, and I want to implement a --silent flag to suppress noise if they don't want it. In this application, errors are most commonly logged when the application ...
19
votes
3answers
22k views

tar cvf or tar -cvf ?

I have learned to use tar without '-' for options, like tar cvfz dir.tar.gz Directory/ but I recently came accross the slightly different tar -czvf syntax (I think the 'f' must be the last option in ...
0
votes
2answers
555 views

Linux command to display the contents of a given file byte by byte with the character and its numerical representation displayed for each byte [closed]

I am looking for the Linux command and option combination to display the contents of a given file byte by byte with the character and its numerical representation. I was under the impression that in ...
42
votes
7answers
3k views

Is `-` used only with cd?

cd - can switch between current dir and previous dir. It seems that I have seen - used as arguments to other commands before, though I don't remember if - means the same as with cd. I found that - ...
3
votes
2answers
42 views

Function with many arguments but only one switch

I am effectively making a recycling bin via some scripts I made. The first script is pretty much an alternative to the rm command (instead of actually deleting a file, it moves it to a deleted folder)...
6
votes
1answer
159 views

How can I delete a file named “--append”? [duplicate]

By mistake I have created a file named : --append. How do I delete it? Simply entering the usual command, rm -f --append, doesn't work.
18
votes
2answers
1k views

Security implications of running perl -ne '…' *

Apparently, running: perl -n -e 'some perl code' * Or find . ... -exec perl -n -e '...' {} + (same with -p instead of -n) Or perl -e 'some code using <>' * often found in one-liners ...
21
votes
3answers
731 views

The precedence of command options?

I know that rm -f file1 will forcefully remove file1 without prompting me. I also know that rm -i file1 will first prompt me before removing file1 Now if you execute rm -if file1, this will also ...
1
vote
0answers
46 views

Using rsync with the verbose option and filtering the information displayed

I am using rsync with the -a -r and -v options to copy files and directories from one server to another. This all works fine. But when I make a change, for example, to a single file on the source ...
3
votes
2answers
432 views

diff --git unknown option

when I try to run diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c I get unknown option (I have installed git via apt-get install git)
2
votes
3answers
126 views

How to read this tcpdump man page?

I am trying to use the tcpdump command in a project and I have some difficulties understanding the help page. SYNOPSIS tcpdump [ -AbdDefhgHIJKlLnNoOpPqRStuUvxX ] [ -B buffer_size ] [ -c count ] ...
5
votes
2answers
4k 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 ...
1
vote
1answer
120 views

Using apropos command with -a to search multiple keywords on CentOS 7

I'm running CentOS 7.0 build 1503. I'm trying to search for commands I don't know the name of by searching the man descriptions for multiple keywords using AND (e.g. search for a command containing ...
133
votes
8answers
50k 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 ...
39
votes
2answers
77k 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 ...
0
votes
1answer
110 views

What's the -alhF flag in ls?

What is the -alhF flag in ls? I can't find it in the man page.