![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| search excat string in another string (grep "fails") | bora99 | UNIX for Dummies Questions & Answers | 0 | 06-05-2008 06:41 AM |
| Help with "grep", need to display several lines | Draken | UNIX for Dummies Questions & Answers | 9 | 04-04-2008 03:46 AM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 01:52 AM |
| grep to find content in between curly braces, "{" and "}," | keshav_rk | Shell Programming and Scripting | 4 | 08-09-2007 10:14 PM |
| invisble with "w" and ip doesnt display with "who" | Micz | UNIX for Dummies Questions & Answers | 4 | 09-12-2003 03:36 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
grep/cat/more -- search in a txt file and display content from a specific "keyword"
Hi,
I have a .txt file Sample: Code:
===================== NEXT HOST ===================== AEADBAS001 ip access-list extended BLA_Incoming_Filter ip access-list extended BLA_Outgoing_Filter access-list 1 permit xxxxxxxxxxxxxx access-list 2 permit xxxxxxxxxxxxxx ===================== NEXT HOST ===================== AEADBMP002 access-list 1 permit xxxxxxxxxxxxxx access-list 2 permit xxxxxxxxxxxxxx access-list 22 permit xxxxxxxxxxxxxx ===================== NEXT HOST ===================== AEADBMP003 ip access-list extended GAA_Incoming_Filter ip access-list extended GAA_GW_Outgoing_Filter access-list 1 permit xxxxxxxxxxxxxx access-list 2 permit xxxxxxxxxxxxxx So all the above information is not showed but starting from that point where it findes the string "AEADBMP002" the output is shown. How do I do that? Thanks, |
|
||||
|
Code:
pg=23
lne=0
while read line
do
str="${str}
${line}"
(( lne = lne + 1 ))
if [[ $(( lne % pg )) -eq 0 ]]
then
echo "$str" | sed -n "/AEADBMP002/,$ p"
str=""
fi
done < file
[[ -n $str ]] && echo $str | sed -n "/AEADBMP002/,$ p"
|
![]() |
| Bookmarks |
| Tags |
| grep or |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|