I just want to share a problem I had this morning using grep -f to obtain the patterns to match from a text file.
$ echo 'sandbox/test/script.py' | grep -G '^sandbox/' sandbox/test/script.py
Using -f option fails:
$ echo 'sandbox/test/script.py' | grep -G -f patterns.txt $ cat patterns.txt ^sandbox/
I didn't understand why grep was failing until I inspected the text file:
$ file patterns.txt /home/miguel/patterns.txt: ASCII text, with CRLF line terminators
This file was being used by different colleagues on different Operating Systems, and someone saved it using the Windows line terminators.