![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jul 2005
Posts: 1
Rep Power: 0
![]() |
Printing only from the matching exp to the end of line?
Hello there!
![]() Is there a way to print only from the matching expression to the end of line ? Example, ( exp: /DC/ ) OU=TI,OU=Clientes,OU=TI-RIO,OU=Unidades,DC=crp,DC=pes,DC=biz Output should be: DC=crp,DC=pes,DC=biz Thanks! hippie ![]() |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4
![]() |
awk ' {if ( $0 ~ /DC/) print substr($0,index($0,"DC")) }' <filename>sample run: original file:
OU=TI,OU=Clientes,OU=TI-RIO,OU=Unidades,DC=crp,DC=pes,DC=biz
OU=TI,OU=Clientes,OU=TI-RIO,OU=Unidades
OU=Unidades,DC=crp2,DC=pes2,DC=biz2
DC=crp,DC=pes,DC=biz,OU=Unidades,DC=crp,DC=pes,DC=biz
this command
awk ' {if ( $0 ~ /DC/) print substr($0,index($0,"DC")) }' filename
produced the following:
DC=crp,DC=pes,DC=biz
DC=crp2,DC=pes2,DC=biz2
DC=crp,DC=pes,DC=biz,OU=Unidades,DC=crp,DC=pes,DC=biz |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|