Reputation: 27
I tried to get "hello" ,but this not work ,it between third and fourth appear of character i
echo "ixaifsdaihelloihd" | grep -oP '(?=i{3}).*?(?=i{4})'
Upvotes: 0
Views: 72
Reputation: 2865
if u need the z
echo "ixaifsdaihellozhd" | {m,g}awk -Fi 'sub("z.*$", substr(_,$!_=$4))'
hello
if just i
's :
mawk -Fi '$!NF=$4' nawk -Fi '$-_=$4' gawk -Fi '$_=$4'
Upvotes: 1
Reputation: 27
echo "ixaifsdaihelloihd" | grep -oP '^(?:[^i]*i){3}\K[^i]+'
or
awk -F'i' '{print $4}' <<< "ixaifsdaihelloihd"
Upvotes: 1