linux_wiki:use_grep_and_regular_expressions_to_analyze_text

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

linux_wiki:use_grep_and_regular_expressions_to_analyze_text [2016/02/28 22:49]
billdozor created
linux_wiki:use_grep_and_regular_expressions_to_analyze_text [2019/05/25 23:50]
Line 1: Line 1:
-====== Use Grep And Regular Expressions To Analyze Text ====== 
- 
-**General Information** 
- 
-About this page/how-to/script.  
- 
----- 
- 
-Filter lines that start with (^) a comment (#) in myfile.txt 
-<code bash> 
-grep "^#" myfile.txt 
-</code> 
- 
-Filter for "auth", ignore case 
-<code bash> 
-grep -i "auth" /etc/ssh/ssh_config 
-</code> 
- 
-Common Grep Options 
-  * -i => ignore case 
-  * -v => invert match (show non-matching lines) 
-  * -c => output the count of matches (or count of non-matching if used with -v) 
-  * -o => print only the matched parts of the matching line 
-  * -n => prefix each line of output with the line number 
- 
-Regular Expression Matching 
-  * ^ => starts with 
-  * $ => ends with 
-  * [ab] => match a or b 
-  * [^ab] => do not match a or b 
-  * ? => previous item optional (match 0 or 1 time) 
-  * * => previous item matched zero or more times 
-  * + => previous item matched one or more times 
-  * . => match any single character (the period) 
-  * {x} => previous item matched exactly x times 
-  * {x,} => previous item matched x or more times 
-  * {,y} => previous item matched at max y times 
-  * {x,y} => previous item matched at least x times, but not more than y times 
- 
----- 
  
  • linux_wiki/use_grep_and_regular_expressions_to_analyze_text.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)