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
ID: 21757760
Hello eberper,

filecontents=`cat filename`

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


Author Closing Comment

ID: 31466049
Thank you for a fast answer and simpel solution.


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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…
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.

867 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