passing file names to awk

Awk and gawk scripting forum.

passing file names to awk

Postby C0ppert0p on September 23rd, 2010, 2:41 am

Hey all,

I have a list of files containing the results of an ifconfig command on a bunch of linux servers:
example:
server1_ifconfig1, server2_ifconfig.txt , server3_ifconfig.txt

I want to generate report using awk to print out the file name and the port name along with the IP address:
example:

server1_ifconfig eth0 addr:10.136.126.124 Bcast:10.136.127.255 Mask:255.255.254.0
server1_ifconfig eth1 addr:10.152.154.134 Bcast:10.152.155.255 Mask:255.255.254.0
server2_ifconfig eth0 addr:10.136.126.125 Bcast:10.136.127.255 Mask:255.255.254.0
server2_ifconfig eth1 addr: 10.152.154.135 Bcast:10.152.155.255 Mask:255.255.254.0
server3_ifconfig eth0 addr:10.136.126.126 Bcast:10.136.127.255 Mask:255.255.254.0
server3_ifconfig eth1 addr:10.152.154.136 Bcast:10.152.155.255 Mask:255.255.254.0

The port info I can do but I can't seem to be able to grab the file name and use it in the output. I'm using awk in a bash do look to read the files:

example:
for i in `ls | grep -e "Link encap" -e "Mask" `
do
awk statement
done
the value "i" disappears in this example. How do I retain the file name "


Thanks
C0ppert0p
New Member
 
Posts: 1
Joined: September 23rd, 2010, 2:11 am

Return to Awk

Who is online

Users browsing this forum: No registered users and 0 guests

cron

dsplabs homelinux bloglinux forums new!travel photography
©2012 dsplabs.com.au