regex - No Output from grep or fgrep with -f option not working -


i have following regular expression in file. btw, im on sunos

ex: file pattern contains following lines:

ora-[0-9] violated 

i have file "datafile" contain following:

0:/scm/123451/test1.sql:dbuser@database:databasedb:no:yes:ora-1234|key violated 1:/scm/123451/test1.sql:dbuser@database:databasedb:no:yes:ora-|key violated 2:/scm/123451/test1_a.sql:dbuser@database:databasedb:no:yes:ora-|key violated 3:/scm/123451/test1_b.sql:dbuser@database:databasedb:yes:yes:violated 4.giga:key violated unique:giga 5.fifa:ora-error null value found:giga 

now, want use command either grep -f or fgrep -f find out lines match pattern file's regular expression. below 2 command didn't work when patter file contained "ora-[0-9]" line.

grep -if ./pattern ./datafile frep -if ./pattern ./datafile 

am missing something, pattern in pattern file needs fixed strings?

try /usr/xpg4/bin/grep not /usr/bin/grep seem results for. there lot of unix commands in solaris /usr/bin old retro-compatibility. /usr/bin/awk notorious.

you can see grep default use of grep command:

which grep 

you can change process placing /usr/xpg4/bin in path variable before come /usr/bin. or use grep alias /usr/xpg4/bin/grep.

add alias in .profile (maybe .bashrc, whatever):

alias grep=/usr/xpg4/bin/grep 

change path (again in .profile or wherever):

example old path --

 path=/usr/bin:/usr/sbin 

example changed path

path=/usr/bin/xpg4/bin:/usr/bin:/usr/sbin 

changing path can affect how existing personal scripts behave, in minor annoying ways.

also consider using egrep -i '(ora|violated)' -- suggestion based on example. not require file of patterns. can many alternations need.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -