regex - Mac OS/X, Grep and Whitespace issues -
i trying use grep on text file in os/x test. known contain following text, including whitespace characters.
(10) business day
my regex search pattern follows:
[\(][0-9]{1,3}[\)] business day
however, doesn't work:
$ grep -eoi '[\(][0-9]{1,3}[\)] business day' *.txt
if remove "day" above, this:
$ grep -eoi '[\(][0-9]{1,3}[\)] business' *.txt (10) business
which expected output egrep -oi or grep -eoi above line.
neither this:
$ grep -eoi '[\(][0-9]{1,3}[\)]\sbusiness\sday' *.txt
nor this:
$ grep -eoi '[\(][0-9]{1,3}[\)] business\sday' *.txt
nor this:
$ grep -eoi '[\(][0-9]{1,3}[\)][[:space:]]business[[:space:]]day' *.txt
nor this:
$ grep -eoi '[\(][0-9]{1,3}[\)] business[[:space:]]day' *.txt
yield desired result, is:
(10) business day
instead, yeild this:
$
(nothing)
i have wasted hours pounding head on desk hours on this. grep not rocket surgery, missing here?????
solved it. need thank vielmetti , suku pointing me in right direction, though.
the problem multiple-fold.
first, problem in relation encoding of text file when saved word document on mac operating system. need save ms-dos format, , not insert line breaks.
once got resolved, command started finding desired text, and, once had figured out macscript approach put grep command vba properly, fell place.
so, review - when saving ms-word document on mac text file, make sure use ms-dos formatting without line feeds.
here's vba command save it:
document.saveas filename:=filepath & docname & ".txt", _ fileformat:=wdformattext, _ lockcomments:=false, _ password:="", _ addtorecentfiles:=false, _ writepassword:="", _ readonlyrecommended:=false, _ embedtruetypefonts:=false, _ savenativepictureformat:=false, _ saveformsdata:=false, _ saveasaoceletter:=false, _ encoding:=437, _ insertlinebreaks:=false, _ allowsubstitutions:=false, _ lineending:=wdcronly
the key settings insertlinebreaks := false and, potentially, lineending:=wdcronly.
Comments
Post a Comment