Warning

 

Close
Confirm Action

Are you sure you wish to do this?

Cancel Confirm
AR15.COM
9/17/2010 2:58:15 PM EDT
Is there a | begin command for Grep.

 Like   grep | begin <–– ???

Want to search for a particular string and then everything past it.


Thanks,
9/17/2010 2:59:08 PM EDT
[#1]
Google "regular expressions" and enjoy.



Hint: ^
9/17/2010 3:07:17 PM EDT
[#2]
you mean show only the rest of the line after "begin" ?
9/17/2010 3:11:29 PM EDT
[#3]
Quoted:
you mean show only the rest of the line after "begin" ?


If I have a config for an F5 for example and I know the VIP but want everything in the config after the vip

9/17/2010 3:12:33 PM EDT
[#4]
Thanks Subnet
9/17/2010 3:26:06 PM EDT
[#5]
egrep -o 'begin.+' filename
9/17/2010 3:33:45 PM EDT
[#6]
The Dark Arts


Quoted:


Google "regular expressions" and enjoy.



Hint: ^






 
9/17/2010 3:38:50 PM EDT
[#7]
Quoted:
The Dark Arts
Quoted:
Google "regular expressions" and enjoy.

Hint: ^


 


Buy Mastering Regular Expressions.
9/17/2010 3:44:34 PM EDT
[#8]

in addition to what has been posted above, i encourage you to explore sed and awk.  a trivial relationship with sed leads to all kinds of neat operations on text files –– such as the one you are looking for.  that said, REGEX is a theme, common with grep, vi, etc.

behold:
http://sed.sourceforge.net/sed1line.txt


# print section of file from regular expression to end of file
sed -n '/regexp/,$p'


i can't tell you how many times i have used the following,

# remove most HTML tags (accommodates multiple-line tags)
sed -e :a -e 's/<[^>]*>//g;/</N;//ba'

to screen scrape some data from a piece of network equipment with a GUI interface.

also see
http://www.pement.org/awk/awk1line.txt

and be sure to google "sed one liners explained" and/or "awk one liners explained".

have fun.

ar-jedi
9/17/2010 3:49:10 PM EDT
[#9]
As always...

The collective comes through.

Thanks!
9/17/2010 3:53:49 PM EDT
[#10]
Go watch Jurassic Park, I think the girl hacker on there does that.
9/17/2010 3:55:10 PM EDT
[#11]



Quoted:


Go watch Jurassic Park, I think the girl hacker on there does that.


Follow it up with The Matrix, if you want some port scanning action with nmap.



 
9/17/2010 3:59:31 PM EDT
[#12]
Regular expressions are your friend...

Then you can get into sed and awk and do some amazing shit.   I'm still pretty green when it comes to regex, but I know enough to be dangerous.  


Of course, you can always use

grep begin /path/to/file

and it will show you every line that has 'begin' on it.