Andreas Moroder wrote:
> Hello,

Hello,

> I have a directory with many files with names made like this two:
> 
> PC=laptop-fortbild,USER=fsigmund,OS=95-98
> PC=INFO-FABIAN,USER=fsigmund,OS=W2K-XP
> 
> This text files may contain a line like this one
> 
> Mac-Adresse: 00:10:D7:09:5E:16
> 
> With grep
> 
> grep Mac-Adresse PC* | awk -F , '{print $1" " $3}' | awk -F = '{print
> $2" "$3}' | awk '{ print $1" "$4}'
> 
> I get a result like this
> INFO-FABIAN 00:30:05:84:91:EB
> laptop-fortbild 00:10:D7:09:5E:16
> 
> I need a small perl script that loops all the files and searches for
> this mac adresses. In the loop I need this two variables ( PC-Name and
> MAC ). There may be files that does not contain the MAC-Adresse line.

Based on your specs this should work:

perl -lne'print $ARGV =~ /^PC=([^,]+)/, " $1" if
/^Mac-Adresse:\s*([[:xdigit:]:]+)/' PC*



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to