date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,393,281,409,000
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 option is a synonym for -Ireplace-str if replace-str is specified. If the replace-str argument is missing, the ef...
muru is right, if you check findutil changelog @line 1645 Major changes in release 4.2.9, 2004-12-05 xargs now supports the POSIX options -E, -I and -L. These are synonyms for the existing options -e, -i and -l, but the latter three are now deprecated. There's an explanation in the man page too, see the -l o...
Why is the xargs -i option deprecated?
1,393,281,409,000
More concise version With "\t": menu-complete in ~/.inputrc create these two files, $ touch one.two.txt $ touch one.four.txt start writing the following, $ ls one hit Tab and you'll get $ ls one.four.txt Now move the cursor to just before four, delete four, write only t, and then hit Tab again. You'll get $ ls one....
skip-completed-text works this way (with your example touch one.four.txt): $ ls one.four # ^ cursor is on the f If you press tab with skip-completed-text on it will complete to $ ls one.four.txt If you press tab with skip-completed-text off it will complete to $ ls one.four.txtour So this setting does not he...
Bash how does skip-completed-text work?
1,393,281,409,000
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. To add an additional empty line consistently to this text file would require two sed commands for each line. This co...
Let us use the Sed POSIX standard to answer the questions. Does the spacing around the semicolon make any real difference? Editing commands other than {...}, a, b, c, i, r, t, w, :, and # can be followed by a semicolon, optional blank characters, and another editing command. Thus /^$/d ; $!G is not compliant, but /^...
Difference between 'sed -e' and delimiting multiple commands with semicolon
1,393,281,409,000
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.
Try this in-order to remove the file: rm -- --append
How can I delete a file named "--append"? [duplicate]
1,393,281,409,000
I'm currently developing a shell script, called up, which shows a usage string on the commandline when called with --help. The output looks like this: $ up --help usage: up [-n levels][--help][--versions][basename]... This looks okay but I'm wondering if I actually need to show the --help and --version options becaus...
This is entirely up to you but most programs do someting like this program --help Usage: program [<options>][<arguments> ...] Options: --help show this message, then exit --something after some spaces for alignment, an explenation follows. You should check out getopt which most programs (this is also ava...
In the usage string of my custom shell script, shall I also display --help and --version?
1,393,281,409,000
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 skips source/ and does not copy anything. If I run: rsync -a source dest then -a implies -r and rsync copies source/ and...
-a, --archive This is equivalent to -rlptgoD. It is a quick way of saying you want recursion and want to preserve almost everything (with -H being a notable omission). The only exception to the above equivalence is when --files-from is specified, in which case -r is no...
rsync: Why doesn't --archive imply --recursive when --files-from=FILE is used?
1,393,281,409,000
In here grep is used with the option -w. I did man grep and grep --help to try to find what the aforementioned option does. Neither output says anything about a -w option. What does that option do? Why does it not appear in manor --help? In case something similar happens again, where else can I check for an answer? I ...
# grep --help | grep -e -w -w, --word-regexp force PATTERN to match only whole words -H, --with-filename print file name with output lines -L, --files-without-match print only names of FILEs with no selected lines -l, --files-with-matches print only names of FILEs with selected lines # grep PRE...
What does grep -w do?
1,393,281,409,000
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 with overriding options. E.g.: pager=less -F -+S When I set less to quit after less than one screen of output and not t...
Well... that would be against the idea of paging... wouldn't it? :-) But to answer your question: I'm pretty sure there isn't. This is from the source code of less: /* * The char won't fit in the line; the line * is too long to print in the screen width. * End the line here. */ if (chopline || hshift > 0) <--- yo...
Is there a way for "less" to truncate lines and still exit after < 1 screen?
1,393,281,409,000
The cp command's infopage offers on the option --preserve= the following: links Preserve in the destination files any links between corresponding source files. Note that with -L' or-H', this option can convert symbolic links to hard links. followed by an example I don't get [now]; anyhow: Qu...
The example in the info page shows you how though the example is a bit hard to follow: $ mkdir c; : > a; ln -s a b; cp -aH a b c; ls -i1 c 74161745 a 74161745 b Let's break that down into its component commands: mkdir c; : creates the directory c/ : > a; : just a quick way of creating an empty file. It is equivalent...
convert soft- to hardlinks with cp
1,393,281,409,000
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 output.mp3 It does not, however; ogginfo clearly shows the information (artist, album, title, ...) in input.ogg and id3info ...
Following this answer on Stack Overflow, I tinkered around and found out that the correct parameter depends on the combination of input and output format/codec. These combinations work as intended: OGG → MP3: -map_metadata 0:s:0 FLAC → MP3: -map_metadata 0:g:0 FLAC → OGG: -map_metadata 0 Using -codec libvorbis. In ...
Mapping metadata with avconv does not work
1,393,281,409,000
How to autologin a specified user with xdm? I know it's possible with other display managers but I wasn't able to figure out how xdm has to be configured to autologin a certain user. Is it possible? Or should I rather remove xdm and simply use an initscript with startx?
I haven't used xdm in a long while but as far as I know autologin is not supported by xdm (and, as per one of the devs, not needed).
How to autologin with XDM?
1,393,281,409,000
How can we create a empty file with the unix name -stuff. It means the name start with -. I tried with touch -stuff but it didn't work.
In general, most utilities have options that begin with -. Most of those utilities have a feature that allows you to specify an argument that is not an option by supplying the special option --. For those utilities, -- means that no further arguments are options. So in your case, you can use touch -- -stuff. For more...
How can I create a empty file whose name begins with a dash? [duplicate]
1,393,281,409,000
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 the result is the same (of course using G to go bottom) and testing each one. But just at a first glance if g and G do...
He, this is mischaracterizing what these commands actually do. p is for "percentage". Try typing 20p and you'll jump to 20% of the file length. Nifty! 20g works too, but it goes to the twentieth line. Simply typing g or p just implies 0g or 0p; because the zeroth line and the zeroth byte are both the file's beginning,...
less command g vs p option
1,393,281,409,000
fgrep --help | fgrep "--help" returns just the whole fgrep --help, how do I return just the lines that have the literal "--help" in them? The quotes don't do anything, nor does \-\-help.
I believe you can use fgrep -- --help to achieve this. The man page mentions fgrep -e --help Quote from http://www.openbsd.org/cgi-bin/man.cgi?query=grep: -e pattern Specify a pattern used during the search of the input: an input line is selected if it matches any of the specified patterns. This option is ...
How do you get fgrep to find the literal "--help"?
1,393,281,409,000
Both a positional parameter ($1, $2, and so forth) and an option (and/or argument) are written directly after a command, so what is the definition or phrasing to explain how to distinct them? In other words, how to formally explain the difference between a positional parameter and an option (and/or argument)?
An option (also commonly called "flag" or "switch") is one type of command line argument. A command line argument is a single word (or quoted string) present on the command line of a utility or shell function. Upon calling a shell script or shell function with a certain number of arguments, each individual argument wi...
How to distinguish between a positional parameter and an option?
1,393,281,409,000
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 #!/usr/bin/env bash function print_status() { echo echo "$1" echo } read -d '' str <<- EOF Setup nginx site-conf...
I guess the question is why read -d '' works though read -d'' doesn't. The problem doesn't have anything to do with read but is a quoting "problem". A "" / '' which is part of a string (word) simply is not recognized at all. Let the shell show you what is sees / executes: start cmd:> set -x start cmd:> echo read -d "...
How does the -d option to bash read work?
1,393,281,409,000
Is it possible to change the mount options of a filesystem after it got mounted (i.e without remounting) ?
In order to change the mount to as read-only, you can run: $ sudo mount -oro,remount /mountpoint
Changing the mount options after a filesystem got mounted
1,393,281,409,000
I have few files that was incorrectly encoded, during extraction, file names now become something similar to -a -b, Now I'm trying to fix this issue with: convmv -f ENCODING -t utf8 --notest * But got: Unknown option: a Unknown option: b So what's the right way to handle it, in a script ?
Because -a and -b start with - the command thinks they are options. To prevent that stick a -- before the list of filenames like this: convmv -f ENCODING -t utf8 --notest -- * That way everything after -- will be treated as regular arguments without trying to process them as options. This is common in a lot of unix c...
Handling filenames that contains a hyphen, within a script
1,393,281,409,000
About curl about to hide the Progress Meter I found many answers through Stack Exchange branches doing mention of -s and -S or simply -sS where -s hides the progress meter -S only shows error messages, it even when -s is used Therefore is suggested work as -sS In some posts were mentioned as a new addition for curl ...
The man page says: -s, --silent Silent or quiet mode. Don't show progress meter or error mes‐ sages. Makes Curl mute. It will still output the data you ask for, potentially even to the terminal/stdout unless you redirect it. Use -S, --show-error in addition to...
curl: when use "--no-progress-meter" over "-sS"?
1,393,281,409,000
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: seriously, why not? When a command has an option -f that requires an argument and an option -v that doesn't, this: cmd -fv ...
First of all, in standard getopt()-style argument processing, arguments don't have to be squished against the option they apply to, they just can be. So if -f takes an argument, both of the following are valid: command -ffoo positional arguments command -f foo positional arguments What you call the "second interpreta...
Why did "argument can be squished against option" prevail over "argument is always separate"?
1,393,281,409,000
Suppose I did some time ago cd /path/to/foo/bar and then evince file.pdf. Now if I want to open file.pdf again I have also to do both steps again (using history). However I would do it in a single step. I.e. I want that not evince file.pdf is written to .zsh_history but evince /path/to/foo/bar/file.pdf. How can I achi...
That's not something that could be done for arbitrary shell code as zsh has no way to know which of the words in the code are actually arguments that a command would treat as a file path let alone as a path relative to the current working directory at the time the code is stored onto the history. For the simplest shel...
How can I force zsh to write automatically complete path to history?
1,393,281,409,000
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 assign desired configuration settings where they will take effect properly. I understand that some of these should be incl...
Given the discussion that has transpired as comments on my original post, I am prepared to conclude that the many changes to the Kernel over the 2+ years since my original install of the UbuntuMATE 20.04 LTS distro are the source of the differences in behaviour observed by the set of 8 ext4 filesystems that were creat...
OS seems to apply ext4 filesystem options in arbitrary fashion
1,393,281,409,000
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) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11)...
Why are the signal lists for kill, killall and pkill not the same? Most likely, because they were implemented differently, with different frames of mind, at different times, by different persons. You should note that all of the commands have some form of a --signal argument that can specify any signal the kernel is ...
Why are the signal lists for kill, killall and pkill not the same?
1,393,281,409,000
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 available command options and what they do? Since I'm mostly following guides to set up specific things on the server, som...
I think you're looking for man command. Try doing man mkdir and look for what the -p switch does. You can use vim style searching here. Use man man for more info on how to use man command.
List of available command options?
1,453,781,082,000
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.
You have to escape the semicolon so that your current shell doesn't see it and use it as a command separator before find gets to see it and use it to terminate the command you're sending to -exec. Also, the manual does state in relevant part: -exec utility [argument ...] ; [...] The expression must be terminated by a...
Why should I escape the semicolon with find?
1,453,781,082,000
For I school project, I have to implement a shell/terminal app. But I am wondering how are command line options parsed, because it appears abit weird to be. For example for the command paste (and I believe other utilities behave similarly) [jiewmeng@JM tmp]$ paste --help Usage: paste [OPTION]... [FILE]... Behavior wh...
paste -d takes a mandatory argument. See the man page -d, --delimiters=LIST reuse characters from LIST instead of TABs This format really means -d LIST or --delimiters=LIST reuse characters from LIST instead of TABs So with paste -d file1, you're setting LIST to file1, and no file name ...
Parsing of command line options
1,453,781,082,000
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 % user@host:dir/ but at a GNU xargs man page this option is not present. Which is the way to do this on, for commands acc...
I am not sure this is what you were expecting, but in the BSD world (such as macOS) -I and -J differ in how they pass the multiple "lines" to the command. Example: $ ls file1 file2 file3 $ find . -type f -print0 | xargs -I % rm % rm file1 rm file2 rm file3 $ find . -type f -print0 | xargs -J % rm % rm file1 file2 fi...
Xargs `-J` Option
1,453,781,082,000
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 -rw-r--r-- 1 user group 283821 janv. 21 12:10 CamScanner 01-10-2022 14.56.jpg I use $ img2pdf to transform each image i...
The issue with your find command is that the command substitution around basename is executed by the shell before it even starts running find (as a step in evaluating what the arguments to find should be). Whenever you need to run anything other than a simple utility with optional arguments for a pathname found by fin...
find -exec command options with basename [duplicate]
1,453,781,082,000
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 utilities, potentially? Here's how to reproduce: touch ./-vR grep hi * Notice that everything not hi is returned, recursivel...
That's a known misfeature of GNU getopt (used for option parsing by GNU tools). grep hi -vR is required by POSIX to look for hi in the file called -vR as options many not be recognised past non-option arguments (like hi here). Most GNU tools or tools making use or the GNU getopt API in the default mode don't honour t...
Bug or Feature? Grep accepts files as flags
1,453,781,082,000
Zsh includes a powerful utility for parsing command line options,zparseopts. Is there an easy way to extract the array of all the command line arguments that don't begin with a hyphen?
Filter the positional parameters $@ with the parameter expansion suffix :#-* to strip elements matching the pattern -* and the parameter expansion flag @ inside double quotes to preserve empty elements. Add the M flag to retain only the elements that match the pattern. non_hyphen_arguments=("${(@)@:#-*}") hyphen_argum...
Is there a simple way to get array of all arguments that do not begin with a hyphen?
1,453,781,082,000
-n noexec ; Read commands and check syntax but do not execute them. Can you give an example of when we will need "noexec" which is one of the Bash options? Can someone give me an example of how to properly use this option?
First, make sure you do not have a file named file in your directory. Create this syntaxErr.bash: echo X > file for i in a b c; echo $i >> file done As you can see, it misses a do after the for loop. See what happens now: $ bash -n syntaxErr.bash syntaxErr.bash: line 4: syntax error near unexpected token `echo' s...
Bash Shell “noexec” Option Usage Purpose
1,453,781,082,000
Most programs use -v to enable verbose mode. Why does the GNU xargs use -t to enable verbosity?
And the shell uses -x (this is short for "execution trace"). For xargs, the -t option enables "trace mode", i.e. it will show you what it's doing by printing the commands that it is executing. Tracing is just another ways of "being verbose". Note that tracing the execution of commands is a particular way of being ve...
Why xargs uses -t to enable verbose mode?
1,453,781,082,000
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 completely silent! and these are printed to output: [flv @ 0x9a5d100]Estimating duration from bitrate, this may be inaccurat...
Try this: mplayer file > /dev/null 2>&1
mplayer -msglevel all=-1 doesn't make it completely silent!
1,453,781,082,000
I see this in my dmesg log EXT4-fs (md1): re-mounted. Opts: commit=0 EXT4-fs (md2): re-mounted. Opts: commit=0 EXT4-fs (md3): re-mounted. Opts: commit=0 I think that means that dealloc is disabled? does mdadm not support dealloc?
mdadm supports dealloc. commit=sec is the time, the filesystem syncs its data and metadata. Setting this to 0 has the same effect as using the default value 5. So I don't get the link between mdadm and commit=0 in your question?
what is commit=0 for ext4? does mdadm not support it?
1,453,781,082,000
Before you hit me with the obvious, I know, the backup option makes a backup of a file. But the thing is, the cp command in general backs up a file. One could argue a copy of a file is a backup. So more precisely, my question is this: what does the -b option do that the cp command doesn't do already? The cp(1) man pag...
It makes a backup copy of each destination file that already exists. The ones that would otherwise get overwritten and lost. $ mkdir foo; cd foo $ echo hello > hello.txt $ echo world > world.txt $ cp -b hello.txt world.txt $ ls hello.txt world.txt~ world.txt $ cat world.txt hello $ cat world.txt~ world That world.t...
What precisely does cp -b (--backup) actually do?
1,453,781,082,000
With the unzip -n /path/to/filename/filename.zip command the compressed file is uncompressed but does not overwrite existing files. This approach is useful when the same compressed file was uncompressed before and some files were either deleted or renamed - so with this n option they can retrieve them. What is same ap...
Two options come to mind that should do what you want. From the tar man page: -k, --keep-old-files don't replace existing files when extracting, treat them as errors Alternatively: --skip-old-files don't replace existing files when extracting, silently skip over them
How to extract the tar.gz file but without overwriting existing files?
1,453,781,082,000
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 TIME CMD ... ... In the same tutorial exists an explanation of the STIME column/header. But through the man ps in the ...
If you’re using the procps implementation of ps (which is the most common on Linux distributions you’re likely to be using), the headers are listed in the “STANDARD FORMAT SPECIFIERS” section. STIME is documented since version 3.3.17, released in February 2021: stime STIME see start_time. (alias start_time)....
ps command: how to know all the headers with their respective descriptions?
1,453,781,082,000
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 here all fine and is expected. Just by mistake was executed ps -P 3384 3395 (observe -P is uppercase) then the output is a...
I don't have any knowledge of why -P is not documented. I wonder if the feature was not fully supported at some point in the past? -P (or -o psr) sets the output to include PSR, which the manual states is: psr PSR processor that process is currently assigned to. There is a comment in the help co...
What does '-P' mean in the context of the 'ps' command?
1,453,781,082,000
Is it possible to create a symbolic link to an executable that executes it with a certain option/argument? I know a workaround would be to create a bash script in one of the PATH directories but can I achieve it somehow with a symbolic link? EDIT: Thanks for the answers, in my case an alias wouldn't do the job because...
No, a symbolic link is a type of file that references the path of another file. Now, if you do: ln -s /bin/cat foo And invoke foo as: $ ./foo -A /proc/self/cmdline ./foo^@-A^@/proc/self/cmdline^@ You'll notice that the first argument that cat/foo received was ./foo and not cat. So, in a way, through that symlink, we...
Symbolic link with option
1,453,781,082,000
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/mysql --general_log /my/log/path.log That doesn't work either (the error message says it doesn't have access) =/ Update: A...
To change options permanently and in the sanctioned manner, edit the files in /etc/sysconfig that have the same name as the service. For example, consider httpd. On one system I have, there are several things you can set: # Processing model HTTPD=/usr/sbin/httpd.worker # Additional options OPTIONS= # Set locale HTTP...
If I'm logged in as root, how do I restart mysql or apache with options?
1,453,781,082,000
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 HTTP OPTIONS requests The configuration may not be fit for current's os and apache. If the configuration is in good st...
First, there is an issue with your .htaccess file: In lines 6-8; you require that the user is authenticated, but only if it's not an OPTIONS request. This is fine. In line 4 however, you require that the user is authenticated as user usernam, regardles of the request method (GET, POST, OPTIONS, etc...) So if you rem...
How to make httpd response 200 for options request?
1,453,781,082,000
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 not follow these conventions quite so, e.g, find, but newer and well-established utilities do too break the rules without ...
The normal convention is that arguments always follow options. The first non-option (the first string on the command line that does not start with -) terminates the options and begins the arguments. Some tools, notably the build tools (compilers, linkers), have always gone against this convention. Another example that...
Why do some utilities parse operands before options?
1,453,781,082,000
TLDR: How is useradd --no-log-init actually used [in GNU/Linux [Debian]? I read the command's man and info page about this option as: »user will not be listed in the lastlog and faillog files ⁄ output«. I know that the PAM module took over most of the actual login work. I understand the lastlog and the faillog command...
If you look at the useradd.c source there is this bit that shows the following. Assuming the command line switch --no-log-init was set, the faillog_reset and lastlog_reset functions are called: if ((!lflg) && (getpwuid (user_id) == NULL)) { faillog_reset (user_id); lastlog_reset (user...
useradd --no-log-init [comprehension question]
1,453,781,082,000
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 point of contention. I'm presently doing this: set -- $(echo $* | sed -e "s/$_ARG/--description=\"$_ID - $_SUMMARY\"/") ...
There are a few issues in your code. One of them is using $* unquoted, which will cause the shell to split the original arguments into words on whatever characters are in $IFS (space, tab, newline, by default) and apply filename globbing on the generated words. Quoting $* as "$*" is also not quite what you want if y...
Replacing command line arguments while preserving spaces
1,453,781,082,000
What is the preferred way to test if a command takes an option? What are the caveats? As a motivating example, at login my shell aliases grep to add several --exclude-dir options but this option is not available on all the machines I access.
You can do a test on dummy data which should succeed if and only if the option is available and working as expected: trap 'if [ -e "$tmp" ]; then rm -rf -- "$tmp"; fi' EXIT tmp="$(mktemp -d)" cd -- "$tmp" mkdir exclude mkdir include echo foo > include/test.txt echo foo > exclude/test.txt [ "$(grep --exclude-dir exclud...
Test if command accepts a specific option
1,453,781,082,000
The question of why some commands rely on manpages whereas others rely on something like the --help flag for providing command usage reference is not new. There is usually a difference in scope between documentation for a command and a command usage synopsis. The latter is often a subset of the former. But even when m...
Commercial unices generally present usage information only in man pages. Having the command itself display usage information is not a traditional Unix feature (except for displaying the list of supported options, but without any explanation, on a usage error). POSIX and its relatives don't talk about anything like thi...
Interactive command usage reference: do you generally have that on Unix?
1,453,781,082,000
I am running a program fls (from the Sleuth Kit) with option -v for verbose mode. However it takes too long, and the program is still running since yesterday. I guess it will run faster without verbose mode, but I am not sure how long it takes to finish running and whether it is worth to stop and rerun it without ve...
As lynxlynxlynx points out, unless the program author makes provisions for it, you cannot change the verbosity while the program is running, but you can keep it from printing to a terminal in case that is a bottle neck. To do this, close the terminal after telling the shell not to send a SIGHUP. Most shells will send ...
Is it possible to disable verbose in the middle of running?
1,453,781,082,000
I know how to restrict standard users to run a command by removing execute permissions for that command. But it's possible restrict standard users to run a command with a specific option/argument? For example a standard user should be able to run the following command: ls but not: ls -l I think that this can be poss...
I think the only way would be to write your own wrapper to the command/utility in question and have it decide what is allowed or not allowed based on the (E)UID of the user who started it. The tools you mention that do this such as chsh or passwd have this functionality built into their implementation. How to write a ...
Restrict standard users to run a command with a specific argument
1,453,781,082,000
I'm sure there used to be an option in less which allowed you to page onto the next file after you reached the end of the current file, so you could just keep *space*ing through a bunch of short files without having to keep :ning to get to the next one. Could someone remind me what it is?
You might try the -e option.
What is the `less` command line option to page to the next file at the end of the current one?
1,453,781,082,000
I am trying to make a shell script which will ask some questions to the user, and will issue a final command with some or other options depending on what the user chose. Right now, the script looks like this: if [[ $a == "y" ]] ; then command --option 1 argument elif [[ $a == "n" ]] ; then command --option ...
Sure, you can store the options to pass in a variable. Your first example could be something like this (also, [[ is a bash feature, not available in POSIX shell): if [[ $a == "y" ]] ; then arg=1 elif [[ $a == "n" ]] ; then arg=2 else arg=3 fi command --option "$arg" argument Your second example: if [[ $b...
Issuing commands with options determined by condition
1,453,781,082,000
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-long-flag) params="$params -m";; --another-flag) params="$params -a";; "-?"|--help) usage e...
You don't need to use a bash array here (but do so if it feels better). Here's how to do it for /bin/sh: #!/bin/sh for arg do shift case "$arg" in --my-long-flag) set -- "$@" -m ;; --another-flag) set -- "$@" -a ;; "-?"|--help) usage exi...
Can a bash array be used in place of eval set -- "$params"?
1,453,781,082,000
On GNU/Linux with fdisk (util-linux 2.20.1), when using, say fdisk /dev/sda3 there are quite some options and the and even an "expert mode" (x). Most of these are explained through the m option. But I can't find an documentation on these, neither in the man not the info page. As I don't want to fumble around with my f...
This page says Expert mode can be used to force the drive geometry to match another drive: x: Enter expert mode c: Change the number of cylinders h: Change the number of heads r: Return to normal mode Additionally, fdisk/README.fdisk on source package tells following story: Extra commands for experts ----------...
fdisk (expert mode) options
1,453,781,082,000
Using the Linux find command -iname option, I want to find and move files that have many different extensions (.pdf, .doc, .xlx, .ppt). I know I can use multiple patterns with grep. But can that also be done with find?
Yes, but not with -iname alone. find itself has an "OR": expr1 -o expr2 Or; expr2 is not evaluated if expr1 is true. So you could do: find /path/to/dir -iname '*.pdf' -o -iname '*.doc' -o -iname '*.xlx' -o -iname '*.ppt' Beware that if you need to perform some action on either of those matching files (l...
Can the Linux find -iname option take more the one pattern
1,453,781,082,000
In the man pages it says: -C list entries by columns However, I really cannot notice any difference between the output of ls or ls -C, could someone explain this to me?
To add what @muru said in the comments; have a look at info coreutils ls `-C' `--format=vertical' List files in columns, sorted vertically. This is the default for `ls' if standard output is a terminal. It is always the default for the `dir' program. GNU `ls' uses variable width columns to displ...
What does the option -C achieve in ls output?
1,453,781,082,000
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 with a translation because a) I don't understand what it means (even with German as mother-tongue) and b) I don't under...
Here's the version from my English manpage: -R, --root CHROOT_DIR Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory. In other words, instead of editing /etc/passwd and friends, you're editing CHROOT_DIR/etc/passwd. For example, you might boot a live CD,...
What is "userdel --root?" supposed to do
1,453,781,082,000
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.
-b specifies the location of users' home directories. On your average Debian box, this will be /home; you can change the default by editing /etc/default/useradd. useradd will add the new username to this path to get the home directory. This means that if you do useradd -b /somewhere ian the new user's directory wi...
difference between useradd -b and useradd -d
1,453,781,082,000
The following command prints a message over ssh : xmessage Message -display :0 & How does it work? there is no -display option in xmessage's man page.
It's included by (obscure) reference. SEE ALSO X(7), echo(1), cat(1) And buried down a ways in X(7): OPTIONS Most X programs attempt to use the same names for command line options and arguments. All applications written with the X Toolkit Intrinsics automatically accept the following options: -display display...
xmessage over ssh
1,453,781,082,000
I want to write a shell script which will take some arguments with some options and print that arguments. Suppose the name of that script is abc.ksh. Usage of that script is - ./abc.ksh -[a <arg>|b <arg>|c|d] <some_string> Now I write a shell script which will take options and arguments #!/bin/ksh # Default Values ...
It is typical for programs to force the "some_string" part to be the last argument so that .abc.ksh "some_string" -a "sample text" is an error. If you do this, then after parsing the options, $OPTIND holds the index to the last argument (the "some_string" part). If that is not acceptable, then you can check at the beg...
How to catch optioned and non optioned arguments correctly?
1,453,781,082,000
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 ] [ -C file_size ] [ -G rotate_seconds ] [ -F file ] [ -i interface ] [ -j tstamp_type ] [ -k (meta...
By convention, the brackets indicate something that is optional. So you can run tcpdump, or tcpdump -c 3 -i eth0, or tcpdump -c 3 -r /path/to/file, etc. Also, unless explicitly indicated, options can be used in any order, so you can run tcp -i eth0 -c 3, etc. Most commands allow options to be clustered when they use a...
How to read this tcpdump man page?
1,453,781,082,000
How to know all DHCP options and values (on the client side, Linux Ubuntu / Debian / ArchLinux ) provided by the server. I need to pass non-standard option to the client by the DHCP option code example: 222-223 Unassigned 224-254 Reserved (Private Use) All DHCP Options here The file /var/lib/dhcp.lease does not cont...
just edit the config file /etc/dhcp/dhclient.conf and add also request # custom dhcp option (72 = www-server) also request www-server; the value is avaible in /var/lib/dhcp/dhclient.lease
How to know DHCP options value on debian/ubuntu and other linux
1,453,781,082,000
mke2fs -r offers Set the filesystem revision for the new filesystem. Note that 1.2 kernels only support revision 0 filesystems. The default is to create revision 1 filesystems. Trying to look up what was meant by that I found loads of screenshots etc. of dumpe2fscontaining the line Filesystem revision #: 1 ...
It seems to really only hinge on what version of the Linux Kernel you're pairing with the filesystem you're attempting to mke2fs and also later use with the resulting ext2,3,4 filesystem. fs_param.s_rev_level = 1; /* Create revision 1 filesystems now */ if (is_before_linux_ver(2, 2)) fs_param.s_rev_level = 0; H...
"mke2fs -r fs-revision-level" - how is this used?
1,453,781,082,000
I have an application that needs a modified LD_PRELOAD. I want to start the application using the originally provided rc script, so I can benefit from an automatically updated rc script on an update of the application. I can't modify the original rc script of course, because any change would be lost on the next update...
The best way is probably to create your own rc-script that you will use instead of the "official one". Otherwise, your rc-script probably includes an external "config" file if you check it. The include may look like this: . /etc/default/mydaemon-config So that you can edit /etc/default/mydaemon-config and do someth...
Automatically start an application with a modifed LD_PRELOAD?
1,453,781,082,000
So I am writing a script that mixes options with arguments with options that don't. From research I have found that getopts is the best way to do this, and so far it has been simple to figure out and setup. The problem I am having is figuring out how to set this up so that if no options or arguments are supplied, for ...
You can use any of the following to run commands when $1 is empty: [[ ! $1 ]] && { COMMANDS; } [[ $1 ]] || { COMMANDS; } [[ -z $1 ]] && { COMMANDS; } [[ -n $1 ]] || { COMMANDS; } Also, you don't need to quote the expansion in this particular example, as no word splitting is performed. If you're wanting to check if th...
How to run a specified codeblock with getopts when no options or arguments are supplied?
1,453,781,082,000
I cannot find documentation on some long, double-dash options of apt, upon which I stumbled with Bash's tab-completion. $ apt install --<TAB><TAB> --allow-change-held-packages --fix-broken --purge --allow-downgrades --fix-missing --reinstall --allow-insecure-repositorie...
--fix-policy is indeed not documented yet, see https://salsa.debian.org/apt-team/apt/-/blob/master/debian/changelog https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=578020: - new "--fix-policy" option to install all packages with unmet important dependencies (useful with --install-recommends to see ...
Are some apt long options undocumented?
1,453,781,082,000
I spent quite a while researching the problem I encountered but none of the getopts tutorial say anything about the leading whitespace in OPTARG when using getopts. In bash(on Ubuntu and OSX), executing below commands: OPTIND=1 && getopts ":n:" opt "-n 1" && echo "OPTARG: '$OPTARG'" and it echos: OPTARG: ' 1' Howeve...
You should just leave out the double quotes around "-n -1", as that is what preserves the space before the 1: OPTIND=1 && getopts ":n:" opt -n 1 && echo "OPTARG: '$OPTARG'" gives: OPTARG: '1'
Strange leading whitespace in OPTARG when using getopts
1,546,521,739,000
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 ./testfile1.txt ./testfile4.txt ./testdir1 ./testfile2.txt ./testdir2 /home/pkaramol/Desktop/testdir $ find . -depth ./testfile...
-print will ensure that the current pathname is printed to standard output. Some flags turns off the default printing of pathnames (-exec for example). -depth will cause a depth-first traversal of the file hierarchy, so that pathnames in directories without subdirectories are handled first (bottom up rather that top d...
Parameters of find command
1,546,521,739,000
I need to find every symbolic link on the server. The version is AIX 6.1. man find says -L Follow symbolic links But find -L is not a proper usage. Usage: find [-H | -L] Path-list [Expression-list] I tried to Google this but couldn't find answers.
You need to pass a top directory name. Some versions of find assume the current directory if you omit it, but not AIX's. Also, -L isn't what you want here: it tells find to follow symbolic links, but that's not what you're asking, you're asking to find symbolic links. find / -type l -print will print out all the symbo...
How to find every symbolic link on a server?
1,546,521,739,000
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: invalid option -- 'b' followed by the usage text. I then tried variations with '-bar' and "-bar" to no avail. How can ...
mmv is nice for tasks like this ex. mmv -n -- '*.ext' '#1-bar.ext' or for any dot extension mmv -n -- '*.*' '#1-bar.#2' Remove the -n once you are happy that it is doing the right thing.
'rename' with expression|replacement with a leading '-' (hyphen|minus)
1,546,521,739,000
I try to delete this file on my solaris machine rm "-Insi" rm: illegal option -- I rm: illegal option -- n rm: illegal option -- s I also try this rm "\-Insi" -Insi: No such file or directory rm '\-Insi' -Insi: No such file or directory so what other option do I have?
Try: rm -- -Insi or: rm ./-Insi
how to delete file that start with "-" [duplicate]
1,546,521,739,000
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 question should be moved to Retrocomputing SE.
This provision was added between Single Unix v2 (1997) and Single Unix v3 (2001). It wasn't done in a vacuum: it had to take into account both the previous specifications and existing practice. If a letter was already specified for some commands, the existing commands would have to be grandfathered in and wouldn't be ...
Why is `-W` reserved for vendor extensions?
1,546,521,739,000
I stumbled upon the following answer on Unix stackexchange, where the -plow option is used with dpkg-reconfigure, but I can't find anything about it in the dpkg or dpkg-reconfigure manpages: http://man7.org/linux/man-pages/man1/dpkg.1.html http://manpages.ubuntu.com/manpages/cosmic/en/man8/dpkg-reconfigure.8.html So...
From the manpage you linked for dpkg-reconfigure: -pvalue, --priority=value Specify the minimum priority of question that will be displayed. dpkg-reconfigure normally shows low priority questions no matter what your default priority is. See debconf(7) for a list. And from man 7 debconf: Another nice featu...
What does "-plow" option do in dpkg-reconfigure
1,546,521,739,000
What does ln -T do? I know the flag does not exist in the BSD version of ln, and it only exists in the GNU version, and I have read the documentation that it will make ln "treat LINK_NAME as a normal file always", but what does that mean and why does the BSD version not have it?
The -T (--no-target-directory) option to GNU ln provides a safety feature that may be useful in scripts. Suppose that you want to create a new name, $newname, for a file $filename, where the new name is maybe provided from external sources. The command ln -T "$filename" "$newname" would then fail if $newname was an a...
What does "ln -t" do [duplicate]
1,546,521,739,000
My system: OS: MacOS / Mac OS X (Mojave 10.14.5) OS core: Darwin (18.6.0) Kernel: Darwin Kernel / XNU (18.6.0 / xnu-4903.261.4~2/RELEASE_X86_64) ls: version unknown, but man ls gives a page from the BSD General Commands Manual Shells: Bash: GNU bash, version 5.0.7(1)-release (x86_64-apple-darwin18.5.0) Zsh: zsh 5.7...
You could execute ls in a subshell: (cd arg; ls -d *[^~])
On a Mac, how can I list contents of a non-current directory without showing backup files (ending with ~), preferably with BSD command ls?
1,546,521,739,000
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, but is there any other way? I mean ways to get that information form the kernel itself, maybe from procfs?
In addition to what @Stephen Kitt said, at least on my Debian system you can find the information in: /boot/config-<version> Where version, in my case, is: 3.16.0-4-686-pae So, issuing: less /boot/config-3.16.0-4-686-pae Spits out the kernel configs in a long list!
How to determine the options Linux kernel was build with? [duplicate]
1,546,521,739,000
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.txt aa ff hh bb soroush@pop-os:~/Desktop$ cat b_file.txt gg tt ss ii cc soroush@pop-os:~/Desktop$ sort -m a_file.txt ...
Merging assumes the files are already sorted: "merge already sorted files; do not sort", so will attempt to merge them into alphabetic order. It is not a simple concatination. So in your example: aa < gg : print aa, move to the next line in a_file ff < gg : print ff, move to the next line in a_file hh > gg : print ...
How does -m option work in sort command?
1,546,521,739,000
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 $OPTARG" >&2 ;; f) echo "-f was triggered with $OPTARG" >&2 ;; \?) echo "Invalid option: -$OPTAR...
You have told getopts that the -d option should take an argument, and in the command line you use -d -f myformat which clearly (?) says "-f is the argument I'm giving to the -d option". This is not an error in the code, but in the usage of the script on the command line. Your code needs to verify that the option-argum...
how to properly parse shell script flags and arguments using getopts
1,546,521,739,000
I'm scripting a sequence of commands I used to enter by hand. The rough outline goes something like this $ echo ${FILENAME_ARGS} | some | big | pipeline | sort -options | etc >temp $ gs -OptionsThatNeverChange `cat temp` Basically, the only thing that changes between runs are the options passed to sort and the files ...
echo ${FILENAME_ARGS} | grep -e - | sort >options echo ${FILENAME_ARGS} | grep -v -e - >files
Passing options to subcommands in bash
1,546,521,739,000
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 example: joe --wordwrap -nobackup file1 file2 file3 Even though I placed --wordwrap (to turn wordwrap off), and -nobackup (t...
Whether an option is global or local is a property of the option, not something you can control. In the documentation, there are two separate lists of options: the first is the list of global options, the second the list of local options. Global options include options like asis, assume_color, etc. and affect the over...
joe (editor) global vs. local options on the command line?
1,546,521,739,000
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 cannot perform a necessary task, warnings are logged when something couldn't be performed, but the application can still...
As you see with curl / ruby, there is no genereal convention. It greatly depends on your application and what can go wrong with it. It also depends on how it is used. For some application it makes sense to have --quiet and --really-quiet flags, for some it's just overkill. Also a --really-quiet flag is usually not req...
Is a "--silent" flag supposed to suppress warnings and errors, or just warnings?
1,546,521,739,000
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). I've managed to allow the script to move multiple files to the deleted folder: sh moveToBin file1 file2 fil3 (simila...
The getopts builtin parses options. You run it only once for all the options, then you process the operands (non-option arguments) that are left. getopts allows the caller to indifferently write e.g. moveToBin -iv file1 or moveToBin -i -v file1, and you can write moveToBin -- -file to handle file names that begin with...
Function with many arguments but only one switch
1,546,521,739,000
Is there a command which will just list all the options for a given command on one or two lines and not as long and words as man or info ?
There is no universal answer here....as the output from a given command is the responsibility of the author of that particular program not anything in the Linux operating system or any of the shells. In general, I try to use --help and hope for the best, but in cases of filter type programs, you might not get anythin...
What is a command that will only show me the command syntax and options?
1,546,521,739,000
I read on the man page defaults Use default options: rw, suid, dev, exec, auto, nouser, async, and relatime. Do the options set depend on a mounted filesystem or not?
In the man page, defaults is listed under Filesystem Independent Mount Options, which means it doesn't depend on the filesystem type.
mount defaults and various filesystems
1,546,521,739,000
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 semantic word? Likewise curl -b , which means curl --cookie, has the same confused question. Can someone make it clear how th...
At first glance it seemed to me that this wasn't answerable except to say, no, options that seem meaningless can always be found. You can make your own program that deliberately has totally meaninglessly named options. (Of course, even then, you might say they are meaningful in their meaninglessness, if they were deli...
is each CLI command option an semantic abbreviation [closed]
1,546,521,739,000
I trying to figure out what the following Mountoption for (v)FAT exactly does (in Linux): allow_utime=### -- This option controls the permission check of mtime/atime. 20 - If current process is in group of file's group ID, you can change timestamp. 2 - Other users can...
On a filesystem that supports normal Unix file attributes, each file has a user who is designated as owner. Only the owner of a file may change its timestamps with utime. Other users aren't allowed to change timestamps, even if they have write permission. FAT filesystems don't record anything like an owner. The FAT fi...
FAT Mountoption allow_utime explained
1,546,521,739,000
TL;DR: What does mount -e <device> do? Overview Over ssh, mount commands are being sent by software that I need to maintain. Twice, the mount commands use an -e option. I don't know what -e is for and can't find a good enough answer. Details In my case, the procedure that is doing this is named "Verify Backup OS" and ...
Did you also read the examples on qnx man mount? mount -e This will re-read the disk partition table for /dev/hd0, and create, update or delete /dev/hd0tXX block-special files for each partition. With your ssh command it makes sense. I understand not much.
What does "mount -e <device>" do?
1,546,521,739,000
Sometimes I see usage information like some_utility [arg [arg [...]]] or some_utility [arg[, arg[...]]] that indicates that you can pass more than one of the same argument. I've also seen it like some_utility [args] or some_utility [arg][, arg][...] Is there a standard way to do this?
Nope, not really, but most times it's rather consistent. Most manuals would list optional arguments with square brackets ([foo]), mandatory ones with angle brackets or no brackets at all (<bar>, baz, latter one often underlined). Also, in almost all cases if the number of arguments is variable, you'll have some kind ...
Correct way to document variable length options in man pages
1,546,521,739,000
I'm looking for way to process shell script arguments that is cleaner and more "self documenting" than getopt/getopts. It would need to provide... Full support of long options with or without a value after '=' or ' '(space). Proper handling of hyphenated option names (i.e. --ignore-case) Proper handling of quoted opt...
Since this question has been viewed so much (for me at least) but no answers were submitted, passing on the solution adopted... NOTE Some functions, like the multi-interface output functions ifHelpShow() and uiShow() are used but not included here as their calls contain relevant information but their implementatio...
Simpler processing of shell script options
1,546,521,739,000
I have a file with the below contents: sh-4.2$ cat file1 example of multiple pattern this is an example of multipole sorry multiple pattern matching using grep so the example is the file itself -example -multiple -bye tata ! While searching for "-example" in the above file, the grep command is not giving the desired ...
Well, you know that the search pattern contains a '-', and you know that when the search pattern contains a '-' you need to use the -e flag. Since you're not using the -e flag the shell is interpreting your "pattern" as an argument (and a parameter) instead. You can see that with: $ grep "-foo" file1 grep: oo: No such...
Why doesn't grep return what I expect when I use single quotes
1,546,521,739,000
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 a command line program that sets the maximum thermal setting for a processor before emergency power off. Lets further ...
I'm assuming you're looking at this from the POV of the utility programmer. This is broad enough that there isn't (and can't be) a single right answer, but some things come to mind. I think most utilities just have a single "force" flag (-f), that overrides most safety checks. On the other hand, e.g. dpkg has a more f...
How to protect potentially destructive command line options?
1,546,521,739,000
Is there a list of all the if switches for use in bash scripting? Sometimes I see someone using it and I wonder what the switch they're using actually does. Example is the -z in this one. I know how to use it, but I don't know where it was derived from. if [ -z "$BASH_VERSION" ]; then echo -e "Error: this script ...
Technically, those are not "if switches" as you state them, but bash conditional expressions used by [[ compound command and the test and [ builtin commands. The list is here.
List of 'if' switches anywhere? [closed]
1,546,521,739,000
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, or are newer than the existing corresponding files in the destination directory. The option is not included in BSD 'mv' ...
You can use rsync instead of mv combining these two options: -u, --update skip files that are newer on the receiver --remove-source-files sender removes synchronized files (non-dir)
The alternative to Option '--update' in BSD command 'mv'
1,546,521,739,000
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 will be equal to test. But if I run script.sh -b test then $1 will be equal to -b. while getopts 'bh' flag; do case "$...
You typically use getopts as: while getopts...; do # process options ... done shift "$((OPTIND - 1))" printf 'First non-option argument: "%s"\n' "$1" The shift above discards all option arguments (including the trailing -- if any) processed by getopts.
Bash get input while flag present?
1,455,096,620,000
I heard that I should never use --nodeps option when I do a rpm -e command. Why does this option exist then?
It exists for broadly the same reasons rm will allow you to delete the filesystem root, or dd will allow you to overwrite the physical hard drive: Linux and unix have a long history of giving you all the ammo you need when you really insist on shooting yourself in the foot. Less flippantly, when something has gone bad...
In which case can I use the option '--nodeps' of rpm command?
1,455,096,620,000
I learned that -i option is interactive mode and -f option is force model in rm command. When I tried both options rm -if test.txt it did not ask me and just deleted it which means -f option overrode -i option. Of course, I would not use options -i and -f at the same time in real life. But I wonder if there is a prio...
In addition to @ckhan's answer: the implementations of rm I worked with always considered the last given argument as final. That means: rm -fi # will work interactively rm -if # will work non-interactively rm -ffifi # will work interactively etc.. For instance, the AIX manpage (AIX 7.2) states: If both the -f...
rm command contradictory options -i and -f
1,455,096,620,000
About the tar command If is executed the command: tar -czf numbers.tar.gz numbers The numbers.tar.gz file is created - from the numbers - in the current directory But for script purposes - by testing - if is executed: tar -czf ~/numbers.tar.gz /home/username/numbers tar -czf /home/username/numbers.tar.gz /home/userna...
Having absolute paths as archive members is a bad idea. That's why GNU tar actually removes the initial / by default (from archive member names and from hard link targets if any). If you're happy for tar do that stripping but want to remove the warning, you can do the stripping by yourself: tar -C / -czf ~/numbers.tar...
tar create: How to avoid to show the "tar: Removing leading `/' from member names" message in the terminal?
1,455,096,620,000
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 <command> with the file -<option> as an argument, <command> will be executed with the option -<option>. Is there then a general safe way to ...
First of all, always enclose your variable between double quotes (there are exceptions to this rule, but you will easily recognize them when the moment comes). The risk that your filename contains space characters is equally high (and probably higher) than a filename that begins with a minus sign. Your first command s...
Passing arguments to a command safely
1,455,096,620,000
In the example bellow: function zp () { zparseopts -E -walk:=o_walk echo "walk: $o_walk" } I get the following output: $ zp --walk "Walking" walk : --walk Walking $ zp --walk zp:zparseopts:2: missing argument for option: -walk walk : Here the argument of the option is mandatory so I am ...
I don't know exactly about zparseopts, but I think getopt doesn't have that and I only see references to mandatory arguments in the manual for zparseopts. You can always just check manually if the resulting option is set: function zp () { if ! zparseopts -E -walk:=o_walk; then return 1 fi if [ $#o_...
How do I make an option (not argument of the option) mandatory in zparseopts?
1,455,096,620,000
I'm learning about the cut command. In the man page of cut, they show the -n option like: -n (ignored) But I didn't understand the usage of the n option or when we would use it. Can anyone explain with an example?
Your man cut describes -n option as "ignored", simply because it is not implemented, in the cut implementation from coreutils. However, the -n option is implemented on some others cut implementations, at least in the *BSD \ POSIX.2 implementation(s). Thus cut from coreutils implements a stub option to it, for portabi...
What is the use of n option in cut command?
1,455,096,620,000
Is there an option in find that allows me to suppress the error messages that I get from it trying to access directories for which I don't have access? I know I can just discard stderr, but it seems like such an obvious need that I'm not convinced that an option that does this does not exist, despite me not finding on...
To avoid getting permission errors from find, you would have to avoid provoking these errors. You do that by avoiding entering directories that are not accessible. Find and display the pathnames of directories that are not readable by the current user, but don't descend into them, GNU find style: find / -type d ! -re...
Discard "access denied" stderr natively in find
1,455,096,620,000
[user@mymachine folder]$ echo `date --date=tomorrow +%Y%m%d` 20160802 [user@mymachine folder]$ echo `date -d=tomorrow +%Y%m%d` date: invalid date `=tomorrow' I'm using Centos 5 if that makes any difference.
The short options or unix style options are usually separated from its argument using a space, but space is not strictly required in some cases For instance echo `date -dtomorrow +%Y%m%d` and echo `date -d tomorrow +%Y%m%d` would work just fine However in case of, echo date -d=tomorrow +%Y%m%d =tomorrow is consider...
Why is one of these date commands valid and the other not?