...
- Intro Unix: Viewing text in files: head and tail
- Intro Unix: Viewing text in files: Text lines and the terminal
- Intro Unix: Writing text: echo - the bash print function
basic grep
The word grep stands for general regular expression parser.
In Unix, the grep program performs regular-expression text searching, and displays lines where the pattern text is found.
Basic usage: grep <pattern> [file] where <pattern> describes what to search for. grep can also take its input on standard input.
There are many grep regular expression metacharacters that control how the search is performed. We'll see more in Part 4: Advanced text manipulation, and at the grep command.
- C-i will perform a case-insensitive search
- grep -n will display line numbers where the pattern was matched
| Tip |
|---|
Because grep's metacharacters are different from metacharacters in bash, it is always a good idea to enclose the <pattern> in single quotes so that the shell treats it as literal text and passes it through as-is to grep. |
More at Intro Unix: Introducing grep
What is text?
So what exactly is text? Inside of files, text isn't characters at all – it is all numbers (0's and 1's), because that's all computers know.
...