nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Script to extract a specific row of data

This is a discussion on Script to extract a specific row of data within the Shell scripting forums, part of the Development/Scripting category; Hi to the gurus & everyone I need to extract some data, actually rows of data from a block of ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 11-15-2005, 11:03 AM
Member
User
 
Join Date: Jul 2005
Posts: 85
Rep Power: 0
ricc
Default Script to extract a specific row of data

Hi to the gurus & everyone
I need to extract some data, actually rows of data from a block of rows..how can I go about it. The block of rows can be something like the output of ifconfig as below.
Code:
eth0      Link encap:Ethernet  HWaddr 00:0E:AB:01:16:60
          inet addr:10.0.17.102  Bcast:10.127.255.255  Mask:255.128.0.0
          inet6 addr: fe80::20e:abff:fe01:1660/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:59303561 errors:0 dropped:0 overruns:0 frame:0
          TX packets:44876565 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:68665797 (65.4 Mb)  TX bytes:18446744073532115470 (1759218604272.3 Mb)
          Interrupt:16
eth1      Link encap:Ethernet  HWaddr 00:0E:AB:01:16:61
          inet addr:10.128.17.102  Mask:255.128.0.0
          inet6 addr: fe80::20e:abff:fe01:1661/64 Scope:Link
          UP RUNNING NOARP  MTU:1500  Metric:1
          RX packets:48517385 errors:0 dropped:0 overruns:0 frame:0
          TX packets:44716078 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:5769058102 (5501.8 Mb)  TX bytes:11973358297 (11418.6 Mb)
          Interrupt:33
eth2      Link encap:Ethernet  HWaddr 00:0E:AB:01:16:62
          inet6 addr: fe80::20e:abff:fe01:1662/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:23591307 errors:0 dropped:0 overruns:0 frame:0
          TX packets:378620 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1813791668 (1729.7 Mb)  TX bytes:62342217 (59.4 Mb)
          Base address:0x2000 Memory:fea80000-feaa0000
Now if I need to extract the 1st and 4th row from each block so that the output can look something like.

eth0 Link encap:Ethernet HWaddr 00:0E:AB:01:16:60
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1 Link encap:Ethernet HWaddr 00:0E:AB:01:16:61
UP RUNNING NOARP MTU:1500 Metric:1
eth2 Link encap:Ethernet HWaddr 00:0E:AB:01:16:62
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

How do I do it. Pls help

ricc
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-15-2005, 03:29 PM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

Very simple, use grep command:

Code:
ifconfig eth0 | grep -E "(Ethernet|UP BROADCAST)"
But since i'm not aware of all your requirements test and it and let me know ...
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Script to extract some part of files: satish1482 Shell scripting 0 03-13-2007 06:30 PM
Select specific rows c341 Shell scripting 6 01-18-2007 03:04 AM
Script for accessing data .. Dastard Shell scripting 1 07-26-2006 12:12 AM
how to extract zip files in linux Linux software 1 01-11-2006 12:30 AM
script to rewrite data. kavi Shell scripting 3 09-18-2005 01:13 AM


All times are GMT +5.5. The time now is 07:13 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36