Computing.Net > Forums > Unix > diff command

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

diff command

Reply to Message Icon

Name: Blaise
Date: August 20, 2008 at 00:14:26 Pacific
OS: Sun Solaris
CPU/Ram: NA
Product: NA
Comment:

Im trying to check whether the contents of file_A is present in file_B. I thought about using grep command but that would be line by line. Im trying to compare a chunk of lines and see if this chunk is present in file_B.

An example of content in file_A:
"aaa bbbcccdddddd
dddd eee fff ggg
hh iiii jjj kkk"

Any advice on how i can do this?
Pls help - thank you.



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: August 20, 2008 at 21:10:21 Pacific
Reply:
0

Response Number 2
Name: Blaise
Date: August 21, 2008 at 00:02:03 Pacific
Reply:

Im afraid not :( The guy is checking line by line which is something i know how to do.

But for my case here, i want to compare several combined lines and see if this combined lines is present in the other file.

e.g.
"I do not like to
go to school since young."

I want to check if the sample sentence above (together with its 'new line') is present in the file being compared.

Maybe i need to make a script to first look for all lines with "I do not like to" and then check if the next line is "go to school since young". I dont want to do this because the lines involved are usually 10-20 lines...hence this method would be quite slow.

Any advice?


0

Response Number 3
Name: sureshht
Date: September 12, 2008 at 06:58:45 Pacific
Reply:

Please try this code: I use this to check archivelog directory with archivelog files.

counter=1
exec 3< ${tmpfile}

while read -u3 line
do
grep "$line" ${tmpfile3} 1>/dev/null
if [[ $? -eq 1 ]]
then
print "Warning: File $line is missing from ***file!!!" >> $tmpfile4
fi

(( counter += 1 ))
done

sureshht


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Unix Installation error ksh - var subs for input ...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: diff command

compare two files and diff file wil www.computing.net/answers/unix/compare-two-files-and-diff-file-wil/7363.html

Version control software www.computing.net/answers/unix/version-control-software/7545.html

Removing blank lines www.computing.net/answers/unix/removing-blank-lines/5139.html