How to catch text in text file using shell script

Posted on 2008-06-11
Last Modified: 2013-12-26
I want to update a file that is stored in ClearCase but I only want to update the file if there is
something to update. To check this I use diff and send the result to a text file. When there are no
differences the text file contains the string "Files are identical".
My problem is that I don't know how to get that string and use it as you can see below.

cleartool setview -exec 'cleartool diff <file1> <file2> > <difflog.txt>' <ClearCase wiew>
if result in difflog.txt neq "Files are identical" ; then
      check out file2
      copy file1 to file2
      check in file2
Question by:eberper
LVL 45

Accepted Solution

sunnycoder earned 250 total points
Comment Utility
Hello eberper,

filecontents=`cat filename`

if [ "$filecontents" != "FIles are identical" ]


Author Closing Comment

Comment Utility
Thank you for a fast answer and simpel solution.


Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Recently, an awarded photographer, Selina De Maeyer (, completed a photo shoot of a beautiful event ( in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now