[olug] bash help (awk/sed)

Eric Pierce eric_olug at yahoo.com
Fri Jun 18 05:37:19 UTC 2004


Ok, I'm stumped.

I'm trying to pull from a file (several files actually) all six digit
combinations followed by a dash and a letter A-F (ex. 123456-D).  Then I want
to append a comma AND the filename that it is pulling from.

Example. 
123456-D,file01.txt
654321-D,file01.txt
...

Here's what I have so far:
filename=pg0001.txt && egrep -o [0-9]{6}-[A-F] $filename | awk '{ print $1
","}'

The output so far is 90% there.  It looks like this:
300150-D,
300141-C,
300258-D,
300132-A,
...

But I can't figure out how to append the $filename after the comma in each
line.  I can't get Awk to resolve the $filename variable.  I've tried a billion
different syntax combinations sticking $filename on the end of the Awk part,
but to no avail.

I also have a sed version, but the problem is exactly the same.
filename=pg0001.txt && egrep -o [0-9]{6}-[A-F] $filename | sed -n
's/\(.*\)/\1,/p

Any ideas anyone?
Thanks,
Eric Pierce



		
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail


More information about the OLUG mailing list