Thursday, June 2, 2016

Text between two matchs using awk and sed

Simple in lines

$ cat /proc/cpuinfo | awk '/processor/,/cpu family/'


A little more complex inside one line

textbetween() {
        sed '/'"$1"'/!d;s//&\n/;s/.*\n//;:a;/'"$2"'/bb;$!{n;ba};:b;s//\n&/;P;D'
        #grep -Po '(?<=Here).*(?= String)'
}

No comments:

Blog Archive