Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
SUSE / openSUSE This Forum is for the discussion of Suse Linux.


  Search this Thread
Old 06-16-2010, 11:03 AM   #1
Registered: Jul 2009
Posts: 83

Rep: Reputation: 15
echo and grep

Hi All,

I just need a line some thing like this in my report

backup status: backup complete successfully

I use the following command in the script

echo "Directory backup:" grep successfull /tmp/backup/$File.log >> /report

I just grep result in my report file after executing the script. Any ideas??

Old 06-16-2010, 12:04 PM   #2
Registered: Mar 2008
Posts: 155

Rep: Reputation: 30
echo "Directory backup:" `grep successfull /tmp/backup/$File.log` >> /report
ought to do it.
Old 06-16-2010, 12:50 PM   #3
Registered: Jul 2009
Posts: 83

Original Poster
Rep: Reputation: 15
That did the trick.

Thanks again.
Old 06-16-2010, 09:17 PM   #4
Senior Member
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,189

Rep: Reputation: 105Reputation: 105
And what if it is not successful? Wouldn't you like it to tell you what happened? Or that it failed? (And what if it spelled successful correctly, and your grep didn't find it? ).

A little creativity with scripting can resolve those questions. Any command returns a success code, and those can be used in IF statements. So, with

if [ 'grep success /tmp/backup/$File.log' ]

you could put appropriate information in your report whether it succeeds or fails.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Grep with Echo Myiagros Linux - General 3 04-26-2010 11:12 AM
Problems with grep when used with echo pavan_pnv Linux - Newbie 3 03-18-2008 07:28 PM
Analyzing /usr/bin/lsattr `echo $PATH | tr ':' ' '` | grep i-- Redshift Linux - Security 2 03-27-2007 09:54 PM
ls | echo, I got blank, why can't echo take the 2nd seat in a pipeline? elinuxqs Linux - Newbie 6 11-24-2006 09:25 AM
BASH: How to NOT echo to screen with "if echo $x | grep ".*"; then" eur0dad Programming 9 07-27-2006 03:14 PM

All times are GMT -5. The time now is 04:20 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration