substrings from all files incl subdirs into csv with dir names

Greetings!

I have multiple files, one per subdirectory, all with the same file name. All subdirectories are one level deep from the main directory.

The data in the files is tab delimited between fields and record delimited with a newline.

The subdirectory names have the date in the name, i.e directory xxxx050109.

I would like to get the second and fifth tab delimited fields and directory name for all records from every file in all subdirectories and put them into a single comma delimited file i.e. field1,field2,directoryname.

Thanks,

Victor

what have you tried?

nawk -F"\t" -v OFS=, 'FNR==1{split(FILENAME,a,"/")}{print $2,$5,a[1]}' *@(0[1-9]|1[012])@(0[1-9]|[12][0-9]|3[01])[0-9][0-9]/*

Untested.

thanks, I'll try this tomorrow, have a nice Memorial day.

still working on the nawk script....the sys admins are making me use gnuwin32 as they won't give me a solaris logon...:frowning:

Finally got it to work with Gnuwin32 and not using the regular expression for the filename.

Thanks for the help.