LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 08-01-2008, 02:16 AM   #1
pooppp
Member
 
Registered: May 2008
Posts: 32

Rep: Reputation: 15
How to extract the interface number from ifconfig -a


1.Ifconfig -a will display all interfaces like eth2,eth3 etc., right..
I need to extract 2,3 like tht only if the interface HW address starts with 00:0C

2.& I got script for extracting HWaddr starts with 00:0C as below
ifconfig -a | awk '/HWaddr 00:0C/{print $1}'
How to store the interface outputed above in a variable?
 
Old 08-01-2008, 02:23 AM   #2
Pearlseattle
Member
 
Registered: Aug 2007
Location: Switzerland
Distribution: Gentoo
Posts: 698

Rep: Reputation: 75
Quote:
How to store the interface outputed above in a variable?
You mean something like

MYVAR=$(ifconfig -a | awk '/HWaddr 00:0C/{print $1}')

echo $MYVAR

?
 
Old 08-01-2008, 03:53 AM   #3
pooppp
Member
 
Registered: May 2008
Posts: 32

Original Poster
Rep: Reputation: 15
u r correct

i tried with wht u gave..but not working
 
Old 08-01-2008, 04:22 AM   #4
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,684

Rep: Reputation: 54
This was only an example - try to understand what it does.
Quote:
You mean something like
Take a look at the output of ifconfig -a first.

For me it outputs the string "Hardware Adresse"
so for me - this example works:

MYVAR=$(ifconfig -a | awk '/Hardware/{print $1}')
echo $MYVAR

only an example too

Last edited by jomen; 08-01-2008 at 04:30 AM.
 
Old 08-04-2008, 04:54 AM   #5
pooppp
Member
 
Registered: May 2008
Posts: 32

Original Poster
Rep: Reputation: 15
Thank u..Working
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP!!! how to use grep to extract a number khong1010 Programming 6 04-18-2008 12:01 AM
Extract a number from a complicated string in python horacioemilio Programming 2 12-25-2007 09:09 PM
Best/Right way to extract disk serial number? itnaa Linux - Hardware 4 08-21-2007 11:13 AM
second ethernet interface will not configure using ifconfig akay Linux - Hardware 0 12-14-2004 06:45 PM
php question - how to extract line number ?? antony_csf Programming 5 09-15-2004 08:08 PM


All times are GMT -5. The time now is 10:13 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration