Unix day 4: Careful when using grep

How to prevent some common mistakes in grep

1. Searching for special characters

You might want to search for a password which might contain a special character like % @ $ or ;

Lets take an example .

It might contain lines like this :


and if you look at the count of lines that have 'sha1$' in it ,

$ grep ‘sha1$’ pass.txt | wc -l

you will get 0 as an output. Thats because the $ is treated as a special character . ( In UNIX $ represents the beginning of a variable ). So to escape the special character we use -F parameter

Unix Solution :

$ grep -F ‘sha1$’ pass.txt | wc -l

Unix day — 3 : Removing dupes from a single file

I share news and Lessons to make possible a safer cyber experience. cyber security educator. ex-McAfee, Consultant snyk.io,sonatype.