Script not working...producing 0's and not number

Below is my script:

 
#!/bin/sh
#echo "Please type oracle-lower case please:"
#read X
#if [[ "${X}" != "oracle" ]]
#then
#       echo "Sorry that is not oracle, try again"
#       exit 1
#else
#       echo Thank you
#fi
find / -name oracle 2>/dev/null |
while read line
do
        bdf 2>/dev/null | grep "$X" | awk 'BEGIN {total=used=free=0}
        {total +=$2
         used +=$3
         free +=$4}
 END    {print "total space for oracle: "total;
         print "free space available for oracle: "free;

 

If I run the entire script, the result is 0's. If I run it from the find down I get numbers? Why cant I run the whole script and come up with numbers?

Bigben

Part of the script is missing? There is no ending } and quote for the awk statement and the done statement of the while loop isn't there either.

It seems to me this script will find any path on the system that contains oracle. So if you have /oracle on your system it will list all subdirectories and files. Suppose that gives you 100 lines. The script will then enter the loop and since X is empty bdf will not get filtered. So what you end up with is 100 * a result of the total of all filesystems that are mounted on your host. It seems to me you do not need the while do loop and I am not sure why you need the find statement.

I did it!! I figured it out. This was my first script Ive wrote, Im so proud. Ive learned alot through this process-lol.

I added ${line} after bdf, then added > junk.txt before done, then after done entered cat junk.txt. And it works!!

I have also noticed that scripting is addicting!!

Now I want to echo the results of the find command?

do I add an echo ${line} before the while loop?

Bigben1220

Probably best if you echo it on a line after the "do".

I added an echo ${line} after the do the | to the bdf
man that sounds confusing and Im the one writing it-lol.

Thansk Im waiting for the output now.

Not sure you wanted to do that. I suppose I meant after the do and before the bdf.

I'm sharing your enthusiasm, though!

...
do
        echo $line
        bdf 2>/dev/null | grep "$X" | awk 'BEGIN {total=used=free=0}
...

Dude your awesome!!

Its working....aw shucky ducky now....what script to tackle next...so many scripts to choose.

Thanks to all for the help!