Web Hosting Talk







View Full Version : simple SH script


clocker1996
12-10-2001, 07:39 PM
Hi guys, hope i'm not posting in the wrong forum.. I was just messing around with shell scripting, and i was trying to make a pretty simple shell script, but ive been getting this error... i'm trying to learn sh, so i was wondering if anyone knew what i could do to fix this?

its lame.. im just tryin to learn..
basically... what i do by hand is this
du -h ./ | sort > size.txt
cat size.txt | grep -v -e html | grep M
so what that does... is show me the DIRS that are only taking up space in MEGABYTES.. like this
# cat size.txt | grep -v -e html | grep M
1.7M ./axcess.netdotnetworx.org
19M .
1.9M ./fleshy.netdotnetworx.org
4.4M ./jigga.netdotnetworx.org
5.4M ./mike.netdotnetworx.org

So what i decided to do was mak ea little .sh
So it will ask me ****... like look, here's the code:

#!/bin/sh
printf "Checking directories..\n"
du -h ./ | sort > size.txt
printf "1. Users in MB"
printf "2. Users in kilobytes.
printf "Enter choice"
read choice
if [ "$choice" = "1" ]; then
cat size.txt | grep -v -e html | grep M
else
cat size.txt | grep -v -e html
fi

but when i run it..i get an error :
# sh space.sh
Checking directories..
1. Users in MBspace.sh: line 8: unexpected EOF while looking for matching `"'
space.sh: line 13: syntax error: unexpected end of file

jks
12-10-2001, 07:47 PM
Originally posted by clocker1996
printf "2. Users in kilobytes.


Didn't you forget an ending " here?

clocker1996
12-10-2001, 09:18 PM
LOL
sorry
<-- idiot

Thanks.