Hi Chaps
Need some help with this, I’m attempting to try and read in the below which is system output for one of the NIC on my server.
2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:4e:97:a1 brd ff:ff:ff:ff:ff:ff
I want to be able to strip away all characters before eth1 including all white space and eveything after eth1: so I’m just left with eth1.
I have tried various regular expression but can’t seem to trap : unless you can think of a better way to do it.
Then print out back to the file handle just the NIC adapter name
This is what I have so far, not much to go on but should give oyu an idea of what im trying to do
#!/usr/bin/perl -w my $nicount = `ip link >/tmp/nic.txt`; open(NICFH, "/tmp/nic.txt") || die "can't open file: $!"; my @NIC = <NICFH>; foreach my $file (@NIC) { $file =~ s/\d\:\s//; print $file; }
In reply to Remove text after and before by muizelaar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |