Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] noob grep ^ question
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
unclecameron
n00b
n00b


Joined: 18 May 2007
Posts: 10

PostPosted: Fri Sep 28, 2007 3:48 pm    Post subject: [Solved] noob grep ^ question Reply with quote

Hi all,

I know this is stupid, but I just can't get it to work. I'm trying to grep through a log file and find instances where a line has one word, and not another right after it, so I'm trying:

grep 'word1' some.log | grep [^'word2']

grep 'word1' | grep -v 'word2'

grep "word1.*[^'word2']" some.log


the pattern in the million lines in the log file I want to NOT list is

word1="is word2"

and I'm looking for the pattern:

word1="any other random text"
_________________
Thanks,
Cameron
San Diego
-----------
Silence is golden...duct tape is silver


Last edited by unclecameron on Fri Sep 28, 2007 5:59 pm; edited 1 time in total
Back to top
View user's profile Send private message
tarpman
Veteran
Veteran


Joined: 04 Nov 2004
Posts: 1083
Location: Victoria, BC, Canada

PostPosted: Fri Sep 28, 2007 3:57 pm    Post subject: Reply with quote

You said you already tried:
Code:
grep word1 some.log | grep -v word2

In what way did that not work?

In grep language, ^ means the start of the line.
_________________
Saving the world, one kilobyte at a time.
Back to top
View user's profile Send private message
unclecameron
n00b
n00b


Joined: 18 May 2007
Posts: 10

PostPosted: Fri Sep 28, 2007 4:09 pm    Post subject: Reply with quote

ah, I sorted it out...awk to the rescue :)


awk '/word1/ && !/word2/' some.log | awk '!/otherwordsequence/' > textfile

That did it...I have to brush up on my grep, but this at least gave me the opportunity to brush up on awk

awk=good :)
_________________
Thanks,
Cameron
San Diego
-----------
Silence is golden...duct tape is silver
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum