View previous topic :: View next topic |
Author |
Message |
unclecameron n00b
Joined: 18 May 2007 Posts: 10
|
Posted: Fri Sep 28, 2007 3:48 pm Post subject: [Solved] noob grep ^ question |
|
|
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 |
|
|
tarpman Veteran
Joined: 04 Nov 2004 Posts: 1083 Location: Victoria, BC, Canada
|
Posted: Fri Sep 28, 2007 3:57 pm Post subject: |
|
|
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 |
|
|
unclecameron n00b
Joined: 18 May 2007 Posts: 10
|
Posted: Fri Sep 28, 2007 4:09 pm Post subject: |
|
|
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 |
|
|
|
|
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
|
|