cat piping awk filename as variable

Hey,

I have the following for-loop:
for i in 0_bla_*
do
        cat $i |awk -v filename=$filename '{if (NR>11) {anz=anz+1}}END{printf("%3$s %1$s %2$s \n", NR-1, anz, filename)}' > $i.dat
done

I want to pipe the filename from cat to awk. But it doesn't work. Has anyone an idea?

Thanks for any help,
Ergy

Comments

  • hi,

    UUOC !*
    for i ...
       awk '...' "$i" #do whatever with awk's internal FILENAME variable
    done
    
    I'm not even sure the for loop is needed...
    try using awk directly on glob.

    *Useless Use Of Cat !
Sign In or Register to comment.