regex - Using sed to find lines with specific keywords -
this in bash using centos
i attempting use sed scan text file find lines contain both phrases "define" , "rev_number" (what lies before, in between, , after doesn't matter). however, want ignore lines have "//" in them because these indicate comments (the source file verilog file).
my code follows:
rev=$(sed -n '/define rev_number/p' text.vh <<< $rev) result=$(echo "$rev") this covers lines include:
define rev_number but want include lines have, say:
define rev_number or number of whitespace between words. ignore lines have
//define rev_number //define rev_number // define rev_number i stumped how achieve this. new bash/shell scripting , sed. c++ guy using strings.
thanks
you can use sed command:
sed -n '/define *rev_number/{\~^ *//~!p;}' file define rev_number
Comments
Post a Comment