LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-19-2008, 08:34 AM   #1
pangcake
LQ Newbie
 
Registered: Jul 2008
Posts: 5

Rep: Reputation: 0
Shell Script


> ifconfig
eth0 Link encap:Ethernet HWaddr 00:a0:d1:78:17:42
inet addr:10.34.119.12 Bcast:10.34.119.255
Mask:255.255.255.0
inet6 addr: fe80::2a0:d1ff:fe78:1742/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3 errors:0 dropped:0 overruns:0 frame:0
TX packets:67 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:138 (138.0 B) TX bytes:7103 (6.9 KB)
Interrupt:17

eth1 Link encap:Ethernet HWaddr 00:1b:77:2a:11:99
inet6 addr: 2002:db2::21b:77ff:fe2a:1199/64
Scope:Global
inet6 addr: fe80::21b:77ff:fe2a:1199/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3 errors:0 dropped:281 overruns:0 frame:0
TX packets:10 errors:0 dropped:1 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2057 (2.0 KB) TX bytes:15461 (15.0 KB)
Interrupt:16 Base address:0x8000 Memory:f1000000-
f1000fff

if i wanna cut only eth1 part as shown below, which command should i use?

eth1 Link encap:Ethernet HWaddr 00:1b:77:2a:11:99
inet6 addr: 2002:db2::21b:77ff:fe2a:1199/64
Scope:Global
inet6 addr: fe80::21b:77ff:fe2a:1199/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3 errors:0 dropped:281 overruns:0 frame:0
TX packets:10 errors:0 dropped:1 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2057 (2.0 KB) TX bytes:15461 (15.0 KB)
Interrupt:16 Base address:0x8000 Memory:f1000000-
f1000fff

i've ever use grep but it prints only one line
so i dont know how can i get it.

Thanks
 
Old 07-19-2008, 09:03 AM   #2
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
ifconfig | grep eth1


This will print all lines containing eth1
 
Old 07-19-2008, 09:07 AM   #3
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
Unless you're doing some kind of programming project, I would just use the command:
Code:
ifconfig eth1
 
Old 07-19-2008, 09:08 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Code:
ifconfig |sed -n -e '/^eth1/,/^$/ p'
 
Old 07-19-2008, 09:09 AM   #5
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
homey: oh yeah...
 
Old 07-19-2008, 09:13 AM   #6
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
Quote:
if i wanna cut only eth1 part as shown below, which command should i use?
Sorry, pangcake my mistake. I misunderstood.

Last edited by dv502; 07-19-2008 at 09:19 AM.
 
Old 07-19-2008, 09:57 AM   #7
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,819
Blog Entries: 1

Rep: Reputation: 1200Reputation: 1200Reputation: 1200Reputation: 1200Reputation: 1200Reputation: 1200Reputation: 1200Reputation: 1200Reputation: 1200
Quote:
ifconig | sed -e '/./{H;$!d;}' -e 'x;/eth1/!d;'
will print only the eth1 paragraph

Quote:
ifconfig | sed -e '/./{H;$!d;}' -e 'x;/eth1/d;'
will print everything BUT the eth1 paragraph
 
  


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
How to ssh from a shell script ? For ppl who can write shell scripts. thefountainhead100 Programming 14 10-22-2008 07:24 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 03:14 AM
I made a shortcut to a shell script and it is using default shell icon... shlinux Linux - Software 2 04-20-2006 07:29 AM
Alias or shell script to confirm 'exit' commands from a shell rose_bud4201 Programming 2 03-08-2006 03:34 PM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 06:32 PM


All times are GMT -5. The time now is 01:58 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration