GREP -O
The GREP -O command is an option of the GREP command that allows only the corresponding parts of a line that correspond to the specified standard.
How to use GREP -O
To use Grep -o , just enter the command followed by the standard you want to look for and the file you want to look for. For example:
GREP -"word" file.txt code>
This will look for the "word" standard in the file.txt and display only the corresponding parts.
Example of Use of GREP -o
Let's suppose we have a file called text.txt with the following content:
LONREMI IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISCING ELIT.
If we execute the command
Grep -o "ipsum" text.txt code>, the result will be:
IPSUM
The Grep -O command found the word "ipsum" in the file and displayed only this corresponding part.
Other GREP options
The GREP command has several other options that can be useful, such as:
- -i : ignores differences between uppercase and lowercase letters.
- -r : Recoverly seeks directories and subdireories.
- -v : Displays only lines that do not correspond to the standard.
Conclusion
The GREP -O command is a powerful tool to search and display only the corresponding parts of a file. Combined with other command options GREP , it becomes even more versatile and useful for text manipulation.