|
-
February 2nd, 2001, 10:10 AM
#1
a truly accidental script
i`m testing and trying different things with shell scripts, mostly because i really don`t know anything of it.
yesterday i was trying some while loops, performing some huge additions; but i guess that i did something very bizarre almost stupid; because all of a sudden, the free space of my hd started to shrinck.
here is a screen dump of the script:
#!/bin/bash
COUNTER=200000
until [ $COUNTER -lt 100000 ]; do
echo -----------------------------> $COUNTER
let COUNTER-=1
done
[Thu Feb 1][23:19:25][root@sicanderbul][/var/tmp:]
>>setterm -dump
to all of you it must be obvious, but this `thing` created a lot of very small files with nothing but `--------` on it.
looking at that right now, i understand why that hapenned,ut what i don`t understand is why the files find their way to 2 diferent directories, /etc/rc.d and /var/tmp directories, why is that?
-
February 5th, 2001, 08:54 AM
#2
When you do:
echo --------> $COUNTER
you're redirecting the exit of the echo program to the file $COUNTER instead of putting the string on the screen (as I suppose you wanted to do, just take it out). Each time $COUNTER changes you create a new file. About the way it goes to these directories I'm not very sure 'bout it and seems to be very strange since you don't change your path during execution.
-
February 5th, 2001, 09:22 AM
#3
thanks elric, yes, i was trying to echo to the screen that `------>`.
looking from a distance, it really looks stupid and obvious.
i guess the files did `find their way` into those directories because i was executing the program while *in* those directories.
thank you very much.
-
February 6th, 2001, 04:14 AM
#4
You could just change $COUNTER to /dev/null, and it wouldn't be a problem.
-
February 6th, 2001, 08:28 AM
#5
Just a note. When you are going to echo a combination of multiple words and variables, enclost them in double quotes. As in:
echo "-----------------------------> $COUNTER"
The problem was that it took the '----' as being test, the '>' as being the redirector and the contents of $COUNTER as being the file name. If you wanted to log this info to a log file, you can add:
FILENAME="filename"
date > $FILENAME
COUNTER=200000
until [ $COUNTER -lt 100000 ]; do
echo "-----------------------------> $COUNTER" >> $FILENAME
let COUNTER-=1
done
If you would like to both view in real time and also save to a file you can do:
echo "-----------------------------> $COUNTER" | tee $FILENAME
The tee command will make a copy of the text to $FILENAME and output another to stdout. -mk
------------------
If it ain't broke, fix it till it is.
If it ain't broke,
Fix it till it is.
-
February 6th, 2001, 09:18 AM
#6
thanks a lot, every body, i was just trying to learn a bit of scripting. as i said, every time i see `that` i see that is totally obvious what it might produce.
mike, thank you very much, i`ll try that script tonight.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|