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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
remove spaces from a file name linux 3 65
wordcount challenge 11 133
Powershell Command to create a csv file using UTF-8 encoding 3 173
Auto Deployment on AWS 3 33
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.

829 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