input.txt:john_Apple01_xyz_1john_Fruit_Apple01_abc_c1john_Apple21_trs_1john_Fruit_Apple21_efg_1john_Fruit_Apple21_tefg_1Desired output:Apple01_xyz_1Apple01_abc_c1Apple21_trs_1Apple21_efg_1Apple21_tefg_1How to use nawk or sed to cut the leading portion everytime the Apple is found in the line ?i'm using KSH in Solaris 10.
How to cut every line from a particular string?
shell script;sed;awk;ksh
@cuonglm's comment illustrates how you can do this with sed:sed -e 's/.*\(Apple\)/\1/' input.txtYou might also consider using good old grep:grep -o 'Apple.*' input.txtCaveat 1 - I don't have any solaris handy, so it might be that the solaris grep doesn't have the -o option.  YMMV.Caveat 2 - If your input file has lines that don't contain any Apples at all, then these won't appear in the output at all.  Not sure if that is the behavior you want.  If not, then the sed answer will suffice.