![]() ![]() GREP supports the command-line options listed in the following table:ĭisplays a help screen showing the options, special characters, and defaults for GREP.Ĭount only: Prints only a count of matching lines. You can list multiple options individually (like this: -i -d -l), or you can combine them (like this: -ild or -il, -d, and so on). The + sign is optional for example, -r means the same thing as -r+. Each individual character is a switch that you can turn on or off: a plus symbol + after a character turns the option on, a hyphen - after the character turns the option off. You can pass options to the GREP utility on the command line by specifying one or more single characters preceded by a hyphen. ![]() To display a list of the GREP command-line options, special characters, and defaults for GREP, enter: This lets you use pipes (vertical bars |) and redirection ("greater than" symbol >). If you do not specify a file, GREP searches the standard input. If you list files without a path, GREP searches the current directory. In addition, you can type a path (drive and directory information). Files can be an explicit file name or a generic file name incorporating the ? and * wildcards. The general command-line syntax for GREP isĬonsists of one or more letters, preceded by a hyphen -, which changes the behavior of GREP. (See The Search String section in this topic.) ![]() You can make GREP search for any string that matches a particular pattern. GREP can do a lot more than match a single, fixed string. Because GREP does not ignore case by default, the strings bob and boB do not match. GREP responds with a list of the lines in each file (if any) that contained the string Bob. ![]() Suppose you wanted to find out which text files in your current directory contained the string Bob. Here is a quick example of a situation where you might want to use GREP. 4.1 Example 1 - Redirecting Output from GREP.However, there is no harm in using quotes. If a regular expression contains no spaces or symbolic characters, it does not need to be Answer C contains spaces, which the shell will interpret as argument separators unless they are quoted.Īnswer A is incorrect. hat The correct answers are B, C, and D.Īnswers B and D contain special characters that the shell will interpret as filename wildcards unless they are Which of the following regular expressions must be quoted? The only patterns that fit that description are those containing St.Īnswer B is incorrect because it lacks uppercase letters Answer D is incorrect because it lacks lowercase letters.ģ. The regular expression describes a pattern of exactly one uppercase letter, followed by exactly one lowercase letter, followed by zero or more of any character. Which two patterns will the regular expression. The other answers are incorrect because the commands work with files.Īny special characters in these commands are file name wildcards, not regular expression metacharacters.Ģ. The first argument of the grep command is a regular expression, whether it contains special characters or not. Which of the following two commands are using a regular expression? The answers you selected are indicated below, along with the text that explains the correct answers. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |