I've lots of files which lines looks like
lotsofblah/XY##_####_morefoo
where # is a number. Now i want to show only the parts
YZ##_####
in the bash, each in a new line of course.

Assuming you want XY to be any two letters... Something like
Would match [two letters][two numbers]_[four numbers] If you wanted, it could be a little more exact, making sure there's a / infront and a _ afterwards, but this is a starting point. Put this together from man grep:



I suppose that XY and YZ are the same, and I'll treat them just as XY
The key is the 

