LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Suse/Novell
User Name
Password
Suse/Novell This Forum is for the discussion of Suse Linux.

Notices

Reply
 
Search this Thread
Old 06-16-2010, 10:03 AM   #1
s_linux
Member
 
Registered: Jul 2009
Posts: 80

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

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

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

Thanks
 
Old 06-16-2010, 11:04 AM   #2
tsg
Member
 
Registered: Mar 2008
Posts: 155

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

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

Thanks again.
 
Old 06-16-2010, 08:17 PM   #4
choogendyk
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' ]
then
else
fi

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


Reply


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 10:12 AM
Problems with grep when used with echo pavan_pnv Linux - Newbie 3 03-18-2008 06:28 PM
Analyzing /usr/bin/lsattr `echo $PATH | tr ':' ' '` | grep i-- Redshift Linux - Security 2 03-27-2007 08: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 08:25 AM
BASH: How to NOT echo to screen with "if echo $x | grep ".*"; then" eur0dad Programming 9 07-27-2006 02:14 PM


All times are GMT -5. The time now is 10:00 PM.

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