Reputation: 3022
am new to regular expressions and i cant handle a regex search using grep.. so thought of trying perl
can you give a perl equivalent to the regex
^\s*\*\s*\[ \][^\*]+?(\w*\:[^\*]+\d$)|([^\*]+[.]com[.]au$)
i want to execute it on a file in linux.. a multiline search... can anyone help me out?
even an awk command that can handle my operation would do..
and am already working on this at the following links
Scope of grep with regular expressions
a regular expression to grep specific paragraphs of a file
when i use the expression as it is,
it gives me: syntax error near "^"
Upvotes: 1
Views: 205
Reputation: 63922
You're looking how to use the above regex with perl from commandline (one-liner)? try:
perl -nle 'print if /regex_here/' < file
e.g.
perl -nle 'print if /bin/' < /etc/passwd
will print out all lines with "bin", and
perl -nle 'print if /^\s*\*\s*\[ \][^\*]+?(\w*\:[^\*]+\d$)|([^\*]+[.]com[.]au$)/' < file
should do what you want.
Upvotes: 1
Reputation: 3022
i managed to work it out using PCREGREP utility
pcregrep -M '(^\s*\*\s*\[ \][^\*]+?(\w*\:[^\*]+\d$)|([^\*]+[.]com[.]au$))' file1
that did it :) thanks @Damian @jack
Upvotes: 1