The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
PERL cgi script... extra character driving me crazy audiophile Shell Programming and Scripting 2 09-08-2008 04:16 AM
How redirect script output from inside of script? alex_5161 Shell Programming and Scripting 4 06-25-2008 10:27 PM
Need some help with this script -- extra eyes gzs553 Shell Programming and Scripting 15 04-25-2008 11:49 PM
exporting number into .csv file in text form (no other extra charc) from shell script Deepak_Rastogi Shell Programming and Scripting 5 03-13-2008 04:08 PM
manipulating csv to add extra row neil546 Shell Programming and Scripting 3 07-16-2007 07:11 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-27-2008
himvat himvat is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 68
Extra output in the script

Hi ,

I am trying to execute the following script.

#!/bin/sh
find . -name "common.log.diff"
if [$? -eq 1]; then
cp common.log common.log.diff
diff common.log common.log.diff > DIFFERENCE.log
cp common.log common.log.diff
grep "ERROR" DIFFERENCE.log
if [ $? -eq 0 ]; then
echo "1"
else
echo "0"
fi
else
diff common.log common.log.diff > DIFFERENCE.log
cp common.log common.log.diff
grep "ERROR" DIFFERENCE.log
if [ $? -eq 0 ]; then
echo "1"
else
echo "0"
fi
fi


This is giving the following output.

./testscript
./common.log.diff
./testscript[3]: [0: not found.
0


In this " 0 " is fine. But I dont know why it is
giving

./common.log.diff &
./testscript[3]: [0: not found.

along with "0"

Kindly suggest. What wrong with my script ?

Regards
  #2 (permalink)  
Old 11-27-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
Change

Quote:
if [$? -eq 1]; then
to

Code:
if [ $? -eq 1 ]; then
Also please use code tags.
  #3 (permalink)  
Old 11-27-2008
himvat himvat is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 68
let me check
  #4 (permalink)  
Old 11-27-2008
himvat himvat is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 68
No w it is giving the following output

./common.log.diff
0


what to do so that I dont get

./common.log.diff

I want only " 0 " as output

Kindly suggest
  #5 (permalink)  
Old 11-27-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
Code:
find . -name "common.log.diff" > /dev/null 2>&1
  #6 (permalink)  
Old 11-27-2008
himvat himvat is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 68
Yes !!!!!

It worked !!!

Thanks a Lot . U helped me a lot.

Regards
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0