Printing out pattern in line

I've scoured the forum and found similar problems but I can't seem to adapt them to help me with my cause.

This is a two-part question.

I have a multi line file generated by ps | -ef

I need to print out a certain type of pattern. The pattern is part static and part dynamic.

It is a file/s(pattern) that contain/s two letters and three to four numbers and sometimes even letter at the end.

e.g GY1020.def, WN093.def and so on. The files(patterns) are located in different directories (some with very long names) so the result from "ps -ef" cuts off part of the extension (.def) so it reads WN093.d

The output from "ps -ef" looks something like this (last two columns shown below):

/bin/ksh /export/home/user/RUN/DEFFILES/GY/GY1020.def G
/bin/ksh /export/home/user/RUN/DEFFILES/WN/RST/WN093.d
/bin/ksh /export/home/user/VB9530.def /more/text/ 1
/bin/ksh /export/home/user/RUN/DEFFILES/LO/LO6002a.def

I want to print out:
GY1020
WN093
VB9530
LO6002a

alternatively: (appending .def for those that get cut off)
GY1020.def
WN093.def
VB9530.def
LO6002a.def

I know "sed" can do this and search for [A-Z][A-Z][0-9][0-9][0-9] or something similar but I cannot get exactly what I want.

The second part of my question; Is there a way to get "ps" to output ALL data and not just cut the end of as shown above?

Some help with this would be very much appreciated.

if on Solaris try: '/usr/ucb/ps -awww'

/usr/ucb/ps -awww | nawk '$2 ~ /[.]def$/ {n=split($2, a, "(/|[.])"); print a[n-1]}'

With sed:

ps -f | sed 's!.*\/\(.*\)\..*!\1!'

with the extension ".def":

ps -f | sed 's!.*\/\(.*\)\..*!\1.def!'

Regards

Thanks for the replies. They helped me a lot.

I thought about matching everything between "/" and "." too, but I was a bit worried that even the "." might get cut off (not to mention that I am no ace when it comes to sed). Hopefully that won't occur. I will look more closely at ps -awww in the future as I run all my scripts on Solaris.

Thanks once again, you guys are awesome.