Pages

Wednesday, August 8, 2012

Grep Wildcarded data from a file

Grepping a Word with numbers in a file

Scenario:
cat SHAMD5.txt
df58a5e677a3e0f4a417744ad3cbb7994fe57ae7        60827   ./lib/ims-systemfields-1.0.1.1.1330974.jar

Failure results:
grep '/lib/ims-systemfields-*.jar' SHAMD5.txt
   -- Doesn't give the output because there is only one occurrence of digit is replaced with  *

Success results:
grep '/lib/ims-systemfields-.*jar' SHAMD5.txt
   -- Gives the expected output because .* represents anything upto jar


Better Successful results:
grep '/lib/ims-systemfields-*.*jar' SHAMD5.txt
   -- Gives the exact expected output because *.* never mind any occurances

No comments:

Post a Comment