Useful Cygwin / Linux commands

grep command – it is used to find pattern/string in the files:

https://www.man7.org/linux/man-pages/man1/grep.1.html

I use this one pretty often:

$ grep -rnie “string” filename.txt

r- recursive – read all the files under each directory

n- prefix each line of output with line number where pattern was found

i – ignore case

e – search for given pattern

 

another example:

grep -n “YOUR SEARCH STRING” * > output-file

 

sed command 

Stream editor for filtering and transforming text

example to show lines between 11115149 and 11145149 for filename input.

$ sed ‘11115149,11145149!d’ filename.txt

Leave a Comment

Your email address will not be published. Required fields are marked *