Home > OS >  How to grep between third appear and fourth appear
How to grep between third appear and fourth appear

Time:07-11

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})'

CodePudding user response:

echo "ixaifsdaihelloihd" | cut -d'i' -f4

CodePudding user response:

echo "ixaifsdaihelloihd" | grep -oP '^(?:[^i]*i){3}\K[^i] '

or

awk -F'i' '{print $4}' <<< "ixaifsdaihelloihd"
  • Related