How to print multiple specific column after a specific word?

Hello....
Pls help me (and sorry my english) :slight_smile:

So
I have a file (test.txt) with 1 long line.... for example:
isgc jsfh udgf osff 8462 error iwzr 653 idchisfb isfbisfb sihfjfeb isfhsi gcz eifh

How to print after the "error" word the 2nd 4th 5th and 7th word??
output well be:
653 isfbisfb sihfjfeb gcz

Can i use in this case awk, or else?
what is the code?

thank you for your help! :slight_smile:

 echo "isgc jsfh udgf osff 8462 error iwzr 653 idchisfb isfbisfb sihfjfeb isfhsi gcz eifh" | awk -F "error" '{split($2,P," ");print P[2],P[4],P[5],P[7]}'

653 isfbisfb sihfjfeb gcz

Thanks.... its help to me... ! :slight_smile: :slight_smile: