The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-20-2007
I-1 I-1 is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 26
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
I want to do a more/grep or cat and start the output from this line "AEADBMP002"...

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,
  #2 (permalink)  
Old 02-20-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
something like this,

Code:
awk '/AEADBMP002/, /\$/ {print}' file
  #3 (permalink)  
Old 02-20-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
sed -n "/AEADBMP002/,$ p" file
  #4 (permalink)  
Old 02-20-2007
I-1 I-1 is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 26
How do I do this per page?

The file has almost 20000 lines
  #5 (permalink)  
Old 02-21-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
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"
Assign the number of lines what you consider as a page to the variable pg
Closed Thread

Bookmarks

Tags
grep or

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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




All times are GMT -4. The time now is 01:55 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0