kvmiphone.blogg.se

Grep i usage
Grep i usage







You might also like: Cod: Command Line Autocomplete Daemon For Bash and Zsh That Detects -help Usageįind out what MULTIPLE one letter command line arguments do by searching the program's -helpįor the second example we'll use grep to search rm -help for what the -r and -f options do, in one go: This also works with command line arguments that begin with 2 dashes, but I didn't use that in an example since those arguments are usually self-explanatory (e.g. Other ways of achieving this is to escape the argument's dash using \\ (e.g.

grep i usage

e allows specifying a search pattern, and it can be used to protect a pattern beginning with a dash ( -). For example, grep -w -e -r (or grep -we -r) would have the same result as grep -w -r in the example above. The grep -w argument is used to match only whole words, so for example it only matches -r, and not -rSOMETHING.Īn alternative you can use instead of the double dash is -e.

grep i usage

This way, grep doesn't try to interpret what follows the double dash as an option/flag. The double dash ( -) signals the end of options for that particular command (the end of the command line flags), after which only positional arguments are accepted. r, -R, -recursive remove directories and their contents recursivelyīy default, rm does not remove directories. Search the rm -help using grep as follows: rm -help | grep -w -r Say we want to find out what the -r argument means from the rm -r command. Let's start with a simple example with only one command line argument that begins with a dash / hyphen. So what's the correct way of using grep to search the -help output for arguments starting with a dash? That's because grep treats -r as an argument for itself, and not as a search pattern. Using grep to search the -help output like this fails:

grep i usage

Ever seen a command with a long list of cryptic, one letter arguments that begin with dash / hyphen, and wanted a quick way to find out what each command line argument does? This article explains how to do this.įind out what a SINGLE command line argument that begins with a dash does by searching the program's -help









Grep i usage