egrep line with perfect mach


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting egrep line with perfect mach
# 1  
Old 08-13-2012
MySQL egrep line with perfect mach

Hi


Input File A
Code:
L006 AL01 0 (OCK)
L006 A006 0 (OCK)
L011 AR11 1 (NLOCK)

Input File B

Code:
L006 AL01 0 (OCK)
L006 A006 0 (OCK)

Need Egrep Command for perfect Match

Thanks
# 2  
Old 08-13-2012
Perfect match? What are you matching? Do you mean FileA matches FileB if both files have the same contents?

Do you mean match lines in FileA and FileB? If so what constitutes a matching line? Do they match if the first field matches, first two fields match, first three fields, all fields match but spacing between fields can be different, the entire lines are identical, or something else?

Are the input files supposed to be sorted? (In your example they aren't.)
# 3  
Old 08-13-2012
I have File A.txt


I want only egrep that line which have only OCK in file B.txt

I am tring below command but it not giving me proper output.
Code:
egrep -i '(OCK)' $fileA.txt> $fileB.txt



Thanks

Last edited by Franklin52; 08-14-2012 at 04:43 AM.. Reason: Please use code tags for data and code samples
# 4  
Old 08-13-2012
I think we're having a language barrier problem. Your egrep command line is looking for any line containing any of the following strings in you input file: "ock", "Ock", "oCk", "OCk", "ocK", "OcK", "oCK", or "OCK". Is that what you want, or do you only want lines that contain the string "OCK", or lines that only contain the string "(OCK)"? What output is it giving you?

What is the output you get when you run the commands:
Code:
printf "fileA is \"%s\", fileB is \"%s\"\n" "$fileA" "$fileB"
ls -l $fileA.txt $fileB.txt

This User Gave Thanks to Don Cragun For This Post:
# 5  
Old 08-13-2012
Does this work?

Code:
 grep  -i '(OCK)' $fileA.txt> $fileB.txt

Guessing that the OP doesn't realise the significance of parens in an ERE.

Last edited by agama; 08-13-2012 at 11:26 PM.. Reason: emphasis
This User Gave Thanks to agama For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

egrep line which begging with

HI Guys, I want egrep from ./txt file which begging from Hello. File A.txt Hello A Abc Abc Xyz Hello B Hello C .. ... Output File B Hello A Hello B (2 Replies)
Discussion started by: asavaliya
2 Replies

2. UNIX for Dummies Questions & Answers

Mach IPC

hey everyone, I'm reading a tutorial on the Mach kernel principles, however, the port and port rights part are kind of confusing to me. I don't know if the book has typos or something but it seems a bit contradictory. It says that "ports, themselves, are not named. It is the port rights that are"... (10 Replies)
Discussion started by: neur0n
10 Replies

3. UNIX for Dummies Questions & Answers

Mach drivers

hello everyone, can anyone tell me what drivers the Mach kernel works with. I'm thinking about experimenting with the Mach kernel, and yes I know there are other kernels that are easier to work with but I just want to use the Mach kernel. So with that being said, can the Mach kernel work with... (11 Replies)
Discussion started by: neur0n
11 Replies

4. Shell Programming and Scripting

egrep 4th line from match

Can some one help me to print 4th line before the match using egrep or grep command options. i have a very large file and i need to search the entire file, look for the match (key word) and print 4th line before the matched key word. (9 Replies)
Discussion started by: ramana117
9 Replies

5. Shell Programming and Scripting

egrep output each file in new line

I have the following script that searches in several files and shows the search results and the matches filename on the screen. find . -exec egrep -wH "word1|word2" {} \; the output from the search display as: file1 word1 word2 I need to show each file search output result on new... (5 Replies)
Discussion started by: konddor
5 Replies

6. Shell Programming and Scripting

Ecaping a line feed in grep/egrep

Is it possible to use the escape sequence: \r to match a line feed in grep/egrep? I want to use a regexp that crosses over two lines, and it does not seem to be possible. (1 Reply)
Discussion started by: Enobarbus37
1 Replies

7. Shell Programming and Scripting

egrep problem | printing next line?????

Hi !!! Dear People, Please help me with the following problem. consider this output: Top 5 Timed Events ~~~~~~~~~~~~ Total Event Waits Time (s) Ela Time ---------------------------- ------------ ----------- ----- CPU time ... (3 Replies)
Discussion started by: user__user3110
3 Replies

8. UNIX for Dummies Questions & Answers

Egrep cheat sheet anywhere? Looking for meaning of egrep -c

Hi I've been searching google and have not found what egrep -c means. Does anyone know where I can get a cheat sheet or what that -c means? thanks, Linda (2 Replies)
Discussion started by: leelm
2 Replies

9. Programming

state mach{ne...

hi, I am looking for some info on how can we implement state machines. Conceptually it appears to be good but while implementing it causes lot of confusion.. I have some doubts regarding this concept. (my explanation may look wired, as I am also not clear on this front) The commonly... (2 Replies)
Discussion started by: parasa
2 Replies

10. UNIX for Dummies Questions & Answers

adding blank line in egrep

I followed the egrep example given in the thread "parse text or complex grep ?". It is exactly what I need...except... how do I insert a blank line after the second line? My exact command is: egrep 'patt1|patt2' filename the result is: patt1 patt2 patt1 patt2 and so on. I would... (2 Replies)
Discussion started by: antalexi
2 Replies
Login or Register to Ask a Question