Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need a file to run a ndstat -l and find the line "Interface speed: 1000 Mbits/sec" and extract the 1000 Mbits/sec and add it to a file.
Thanks for the help
jrmontg

Typical output of the ndstat -l command looks like this (# comments are mine):# start ndstat output
DLPI Module Info: 2 SAPs open, 16 SAPs maximum96687 frames received destined for an unbound SAP
MAC Driver Info: Media_type: Ethernet
Min_SDU: 14, Max_SDU: 1514, Address length: 6
Interface speed: 1000 Mbits/sec
# End ndstat outputHow about an awk script that searches for the first two fields equal "Interface" & "speed:" and print everything from field 3 to the end of the line:
#!/bin/ksh
# myscript.ssndstat -l|awk ' { if( $1 == "Interface" && $2 == "speed:")
for(i=3; i <= NF; i++)
printf("%s ", $i) } 'I don't know what "add it to a file" means, but executing:
myscript.ss >> new.file
appends the output of myscript.ss to new.file

Thanks
that script got me this:
1000 Mbites/sec 1000 Mbites/sec
Is there a way just to get it to list it once?jrmontg

Without seeing the output of your 'ndstat -l' command, I can't tell for sure. It looks like you have two different lines that have the same output. If that's the case, why don't you exit the awk script after the first one:
ndstat -l|awk ' { if( $1 == "Interface" && $2 == "speed:")
for(i=3; i <= NF; i++)
{
printf("%s ", $i)
if(i == NF)
exit(0)
}
} '

![]() |
Display a character n tim...
|
Shell script encryption
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |