Extra output in the script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extra output in the script
# 1  
Old 11-27-2008
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  
Old 11-27-2008
Change

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

Code:
if [ $? -eq 1 ]; then

Also please use code tags.
# 3  
Old 11-27-2008
let me check
# 4  
Old 11-27-2008
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  
Old 11-27-2008
Code:
find . -name "common.log.diff" > /dev/null 2>&1

# 6  
Old 11-27-2008
Yes !!!!!

It worked !!!

Thanks a Lot . U helped me a lot.

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Script when scheduled in Crontab gives extra records in output

Hi, We have created a script that's checks the latency of IIDR subscription by fetching details from a config file (that contains subscription details) and running the CHCCLP command. The out put is then concatenated in a csv file. Once all subscription details are saved the script send a mail... (7 Replies)
Discussion started by: ab095
7 Replies

2. Shell Programming and Scripting

Extra data in output file

Gents, I did a small scritp called make_file It read file1.txt file and generate an output as attached.. But the script is showing more extra information not needed. I have attached the output file as desired. Could you please help to fix this scrip to get the correct output Thanks... (4 Replies)
Discussion started by: jiam912
4 Replies

3. Shell Programming and Scripting

Extra Space in output - remove

Hi All I am trying to perform the below operation -count=`cat abc.txt | wc -l` echo$count 5 Head=Start"$DATE"00000"$count"File echo $HEAD START15020300000 5File There is a space coming before 5 which is not needed . How to ignore that . (4 Replies)
Discussion started by: honey26
4 Replies

4. Shell Programming and Scripting

Compare two files with different number of records and output only the Extra records from file1

Hi Freinds , I have 2 files . File 1 |nag|HYd|1|Che |esw|Gun|2|hyd |pra|bhe|3|hyd |omu|hei|4|bnsj |uer|oeri|5|uery File 2 |nag|HYd|1|Che |esw|Gun|2|hyd |uer|oi|3|uery output : (9 Replies)
Discussion started by: i150371485
9 Replies

5. Shell Programming and Scripting

How can I stop the unix script from trimming extra spaces?

I have a file which contains certain records about users. the row length is always fixed to 205 characters. Now I want to read each record line from the file, substring some portion out of it and put into another file. But I have observed that my script is trimming the extra spaces I have used for... (4 Replies)
Discussion started by: Pramit
4 Replies

6. Shell Programming and Scripting

Output from sql session having an extra whitespace

I am running a sql session within a shell script. Later I am performing some validations on the value coming from the sql session. The problem is that, the value I am getting from sql session have an extra white space at the begining(I am actually, assigning the outcome of the sql session to a... (5 Replies)
Discussion started by: mady135
5 Replies

7. Shell Programming and Scripting

The same script with extra variables seems to fail

Hey everyone, I have a problem with a certain shellscript. I have a script like this: #!/bin/sh template=$1 for values in {60,150,240,330}\ {60,150,240,330}\ {60,150,240,330}\ {60,150,240,330}; do set $values X=$1; Y=$2; Z=$3; M=$4 mkdir "X$X-Y$Y-Z$Z-M$M" cp... (2 Replies)
Discussion started by: mario8eren
2 Replies

8. Filesystems, Disks and Memory

vxdisk list output showing extra LUNs

hi fren i am facing this problem i have sun 6140 storage 30 volumes bt my vxdisk list output is showing 37 disk which shd nt b there has neone faced this proble earlier vxdiks list output is like this SUN6140-2_0 auto - - online c4t201700A0B84853C0d2s2 SUN6140-2_1 auto - - online... (13 Replies)
Discussion started by: bond_ankur
13 Replies

9. Shell Programming and Scripting

csh script for deleting extra spaces in text file

I am new to scripting and I needed to know if there would be an easy way to delete extra spaces in a text file. I have a file with three rows with 22 numbers each, but there is extra spaces between the numbers when it gets output by this program AFNI that I am using. What script would help delete... (2 Replies)
Discussion started by: hertingm
2 Replies

10. Shell Programming and Scripting

Need some help with this script -- extra eyes

I have two issues with this script. 1. I cannot seem to get my counters to count correctly. 2. My function to eject to CAP1 or CAP2 is hung in a loop and doens't exit back to the previous function. I would like to be able to select which cap to eject to . Each cap holds only 40 tapes, so when one... (15 Replies)
Discussion started by: gzs553
15 Replies
Login or Register to Ask a Question