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 :

sha1$e4da8$bf4546fa5fedfb7c1b42727b3f85208d07d95851

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

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

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
23

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.