Saturday, January 21, 2017

IndexOf Subtring in String

function indexOf {
    local a=$1;
    local b=$2;
    echo $(($(expr match "$a" ".*${b}") - $(expr length "$b")))
}


echo 'thiago d' 'ago' | awk '{ last=$NF; $NF=""; print $0; print index($0,last)}'

No comments:

Blog Archive