regex - Why does grep matches all the lines no matter what the pattern -
i'm having problem using grep. have file http://pastebin.com/hxaccica want check patterns. , when i"m trying search grep returns lines provided pattern exists in given file.
to explain more code i'm running
grep -f "enviro" "$file_pos" >> blah
no matter else try if provide whole line pattern bash returns lines.
these variations of i'm trying:
grep -f "e20" "$file_pos" >> blah grep e20 "$file_pos" >> blah grep c:\e20-ii\enviro\ssnhapacs480.dll "$file_pos" >> blah grep -f c:\e20-ii\enviro\ssnhapacs480.dll "$file_pos" >> blah
also strange reasons when adding -x option grep, doesn't return line despite fact exact pattern exists.
i've searched web , bash documentation cause couldn't find anything.
my final test following
grep -f -c 1 "e20" "$store_pos" >> blah #store_pos has same value $file_pos
i thought maybe printing lines after result not case. using blah file see output. i'm using linux mint rebecca. although naming quite familiar question not similiar why grep match lines pattern "\'"
and new bash. suspect error might due main file http://pastebin.com/hxaccica rather code?
from comments, appears file has carriage returns delimiting lines, rather linefeeds grep
expects; result, grep
sees file 1 huge line, either matches or fails match whole.
(note: there @ least 3 different conventions how delimit lines in "plain text" file -- unix uses newline (\n
), dos/windows uses carriage return followed newline (\r\n
), , pre-osx versions of macos used carriage return (\r
).)
i'm not clear on how file wound in format, can fix with:
tr '\r' '\n' <badfile >goodfile
or on fly with:
tr '\r' '\n' <badfile | grep ...
Comments
Post a Comment