help need for pattern matching

Hi,
I have a shell script that gives output in the form :

abc/xyz/delays/A1toB1_000000
pqr/trf/delays/AtoB_45678567
etc

I need tget the pattern A1toB1 , AtoB etc from this output.
Can some one please tell me how this can be done.

Thanks,
Himi

Are their positions constant. I mean does it come after the specific number of "/"

yes , the positions are constant

suppose output will be stored in a file called file1.
execute the following command :
awk -F"/" '{print $4}' file1 cut -d"_" -f1

Actualy the complete command is something like this :

ls -a | grep delays

this produces the following output:

abc/xyz/delays/A1toB1_000000
pqr/trf/delays/AtoB_45678567
etc

I want that the output displayed on running the script to be :

A1toB1
AtoB
and so on.

awk -F"/" '{print $4}' file1 | cut -d"_" -f1

ls -a | grep delays | awk -F"/" '{print $4}' file1 | cut -d"_" -f1

so i need to store the output of grep in a file called file1?

Its working great.. thanks!!!! :slight_smile:

ls -a | grep delays | nawk -F'[/_]' '{print $4}' filename

nawk -F'[/_]' '/delays/{print $4}' text