Grep is a command line tool that searches files for lines containing a match to the given keyword and returns the entire matching line by default. Searches with grep are case-sensitive but can be made case-insensitive using the -i flag. Grep also supports metacharacters like $ to search for matches at the end of a line, ^ to search for matches at the beginning of a line, and . to match any single character.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
31 views
Features of Grep:-: Tasks
Grep is a command line tool that searches files for lines containing a match to the given keyword and returns the entire matching line by default. Searches with grep are case-sensitive but can be made case-insensitive using the -i flag. Grep also supports metacharacters like $ to search for matches at the end of a line, ^ to search for matches at the beginning of a line, and . to match any single character.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1
Features of Grep: Returns entire lines with matching keyword.
Searches are Case-Sensitive, by default.
(Use i to enable Case-Insensitivity) Tasks:1. Create a file with content 2. Perform Queries a. grep Linux grep.test.txt Returns all matches for the case: Linux b. grep -i linux grep.test.txt Returns all cases of word: linux c. grep 2 grep.test.txt Returns all lines containing the number 2 3. Metacharacters a. grep 2011$ grep.test.txt -Returns lines that terminate with: 2011 Note: $ means to search for content at the end of the line b. grep ^Linux grep.test.txt -Returns lines beginning with: Linux -Case Sensitive c. grep -i ^Linux grep.test.txt -Returns lines beginning with: Linux -Case Insensitive
d. grep L. grep.test.txt -Searches for L followed by any characters