Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cat piping awk: filename as variable

Status
Not open for further replies.

ergy

Technical User
Joined
Sep 16, 2009
Messages
4
Location
DE
Hey,

I have the following for-loop:

Bash:
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
 
probably what you want is:
cat $i |awk -v filename=$i ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top