bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep help with cygwin


From: sdnabble
Subject: Re: grep help with cygwin
Date: Thu, 3 May 2007 10:57:28 -0700 (PDT)

Thanks for the info.

I ended up writing a perl script instead. for this particular problem, I
read the whole file into a list and then used the following if statement. 

if ( ($listitem !~ /PLACED/) && ($listitem =~ /];/) )

Your way looks much nicer, I'll try to use that.


Benno Schulenberg-3 wrote:
> 
> sdnabble wrote:
>> I want to first parse through File1.txt and find all the lines
>> missin the XY information.
> 
> $ grep -v X.Y. File1.txt
> Some_string_1];
> Some_string_2];
> 
>> Then find that same string in 
>> file2.txt that have the needed XY information.
> 
> Difficult.  If those strings were on lines by themselves, it 
> would be easy.  Now you have to find a way to only grab the 
> "Some_string_n" part.  If this "_1", "_2" are a distinguishing 
> trait, then this would work:
> 
> $ grep -v X.Y. File1.txt | grep -o ".*_[0-9]"
> Some_string_1
> Some_string_2
> 
> If that produces the expected set of strings, then do:
> 
> $ grep -v X.Y. File1.txt | grep -o ".*_[0-9]" | grep -F -f - File2.txt
> inst "Some_string_1" PLACED in X2Y1;
> inst "Some_string_2" PLACED in X3Y1;
> 
>> And finally append 
>> the information to file1.txt
> 
> Use '>>' to pipe the output there:
> 
> $ grep -v X.Y. File1.txt | grep -o ".*_[0-9]" | grep -F -f - File2.txt
> >>File1.txt
> 
> 
>> grep "Some_String_" file1.txt | grep [^P]LACED > tempout.txt
>>
>> Right away it didn't work. For some reason I can't say look for
>> Some_String_ NOT containing the word PLACED.
> 
> Use the option '-v' to look for lines _not_ containing a pattern.
> 
>> Isn't that how to use "NOT"?
> 
> 'grep [^P]LACED' looks for the patterns aLACED, bLACED, cLACED, and so on,
> it looks for every occurrence of .LACED, excepting PLACED.
> 
> Benno
> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/grep-help-with-cygwin-tf3683908.html#a10310140
Sent from the Gnu - Grep mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]