|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
grep/egrep end of pattern
Hi I use arp to get the mac-addresses of my hosts. Code:
# arp -a | grep 192.168.0. e1000g0 192.168.0.1 255.255.255.255 o 00:00:00:00:00:01 e1000g0 192.168.0.11 255.255.255.255 o 00:00:00:00:00:02 e1000g0 192.168.0.2 255.255.255.255 00:00:00:00:00:03 e1000g0 192.168.0.22 255.255.255.255 o 00:00:00:00:00:04 e1000g0 192.168.0.3 255.255.255.255 00:00:00:00:00:05 e1000g0 192.168.0.33 255.255.255.255 00:00:00:00:00:06 How can I grep/egrep for just one host? I'd like to have the following: Code:
# arp -a | grep "192.168.0.1" e1000g0 192.168.0.1 255.255.255.255 o 00:00:00:00:00:01 and not Code:
# arp -a | grep "192.168.0.1" e1000g0 192.168.0.1 255.255.255.255 o 00:00:00:00:00:01 e1000g0 192.168.0.11 255.255.255.255 o 00:00:00:00:00:02 |
| Sponsored Links | |
|
|
|
#2
|
|||
|
|||
|
Try the -w option of grep.
Regards |
| Sponsored Links | ||
|
|
|
#3
|
|||
|
|||
|
Thanks. Exactly what I need.
Sorry for my stupid question ![]() |
|
#4
|
|||
|
|||
|
you can also try out as
arp -a | grep "192.168.0.1 " |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Why should you use a workaround if there's an option for?
Regards |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Quote:
![]() But I have an other question: How can I grep/egrep for exactly two (192.168.1 AND 192.168.2 for example) hosts? Code:
arp -a | egrep '192.168.0.(1|2)' This egrep delivers four hosts. Last edited by domi55; 05-12-2009 at 08:27 AM.. |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
arp -a | awk '{print $2}' | grep "192.168.0.[1-2]$"
check this out |
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to grep or egrep pattern of apache access_log file | lamoul | Solaris | 2 | 05-06-2009 09:21 PM |
| Simple egrep pattern | blondie53403 | Shell Programming and Scripting | 7 | 04-14-2009 11:55 AM |
| HOW to egrep fo a pattern | eliewadi | Shell Programming and Scripting | 1 | 05-15-2008 10:42 PM |
| egrep a certain pattern | trust123 | UNIX for Dummies Questions & Answers | 5 | 06-29-2007 08:23 AM |
| grep/awk/egrep? | whugo | UNIX for Dummies Questions & Answers | 3 | 01-19-2006 11:51 PM |
|
|