Search and find the string and output to a new file.

Hi I want to search the following in the entire file and put them in a diff file.
file 1 contains :

Non error probabilities are not decreasing in curve 1GEORGE_SGD_SUB
Mid Point RESCAP_SGD_SNU curve have errors
Non default probabilities are not decreasing in curve ABF_JPY_SUB
Mid Point BSD_INR_SUB curve have errors
Non default probabilities are not decreasing in curve AA_SGD_STR
Non default probabilities are not decreasing in curve RFG_USD_SRN

and the output file should contain.
1GEORGE_SGD_SUB
RESCAP_SGD_SNU
ABF_JPY_SUB
BSD_INR_SUB
AA_SGD_STR
RFG_USD_SRN

How can i do this.

Regards,
Szch

perl -ne 'print $1."\n" if /([0-9A-Z_]{3,})/g;' file

Or...

sed 's/\([A-Z0-9_]\{2,\}\)/\n\1\n/' foo | sed -n '/^[A-Z0-9_]\{2,\}/p'

Thanks mates,,, it works great...thanks again..:slight_smile: