file io - copy everything after matched pattern till end of each line -
i have file
abcjjsdxsaxsaskjakjxas, sham nkhhjkllllhhghhkjlkll
jjjusdiolsjshsnsjsusjus sham ooushsjsysghsjsjksksls
ilsjsusynshshssjsjgsgtsttwfwgwywuwnwhww owuwywtwbwwh sham
losuyeeegftgsyshshsh sjsisusns sisisusus lckcncncmcn owueyete sisuysyshsbs sham hdndhgdgebeheodjdjdhdgdgd
loshsbvsgshjsjssmms twrqeqqgtw wtwrfsxvxvzflld spsishdvd dkdididjd shsh shshsh llll sham iiiiyhh
i want print after sham of each line different file. want output line wise only. have tried various things using awk in unix.
thanks, sham
i got answer here
awk '{for(i=1;i<=nf;i++)if($i~/sham/)print $(i) $(i+1) $(i+2) $(i+3) $(i+4) $(i+5) $(i+6) $(i+7)}' file
u can adjust print cammand per ur requirement..