LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Still a newbie (https://www.linuxquestions.org/questions/programming-9/still-a-newbie-299637/)

spud 03-09-2005 10:44 AM

Still a newbie
 
Hi
If you trace the forums back you can probably see where im going......

Anyway
Im very very new to this so bear with me...
Im trying to edit a text file extracting only certain information from it...
ie..

FILE -- arp.table

? (10.10.10.10) at 00:00:00:AA:AA:AA [ether] on eth0
? (10.10.10.11) at 00:00:00:BB:BB:BB [ether] on eth0

RESULT WANTED

10.10.10.10 00:00:00:AA:AA:AA
10.10.10.11 00:00:00:BB:BB:BB
and so on

can anyone help
Many thanks
And for people like me this forum is a god send

TheLinuxDuck 03-09-2005 10:53 AM

What method are you using to exit the text file? If you only need to parse the data and retrieve the result you wish, perl is a good choice. A regex can do that for you.. bash can do it, too (possibly using awk/sed -- I don't know these very well) but not as easily as perl. I guess the question is, what language are you wanting to use?

spud 03-09-2005 10:59 AM

Basically im open to offers as im only just starting in this field. You said that Perl would be the easier choice so

How could i get perl to output only the results wanted as above.

zeropash 03-09-2005 11:05 AM

is this sufficient?
cut -d' ' -f2,4 arp.table | tr -d '()'


TheLinuxDuck 03-09-2005 11:22 AM

Nice zeropash. I tend to think 'perl' first in many situations, and usually there are ways to do it already. That's nice. (=

zeropash 03-09-2005 11:37 AM

I am a lazy guy ;)

spud 03-09-2005 12:16 PM

Thanks a lot, thats worked great.


All times are GMT -5. The time now is 01:31 PM.