[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [K12OSN] some scripting help



On 5/11/07, Les Mikesell <les futuresource com> wrote:
Huck wrote:
> found this in my archives:
>
> Wrote one for you....try this...make it executable.
>
>
> !#/bin/bash
> for x in `ls /home`; do
> echo "Doing $x ..."
> cd /home/${x}/.mozilla/firefox/*.default/Cache
> rm -Rf *
> done

Error checking tends to be optional in shell scripts, but something
nasty might happen if you had an ordinary file in /home.  The cd would
fail and you'd proceed to remove everything in and under your current
directory...
I'd recommend a change to:
cd /home/${x}/.mozilla/firefox/*.default/Cache && rm -Rf *
which means only execute the rm if the cd succeeds instead of doing it
unconditionally on the following line.

I'm not always this pedantic - just when 'rm *' is involved...


Agreed. So would this be better?

!#/bin/bash
for x in `ls /home`; do
echo "Doing $x ..."
rm -rf  /home/${x}/.mozilla/firefox/*.default/Cache
done



--
Robert Arkiletian
Eric Hamber Secondary, Vancouver, Canada
Fl_TeacherTool http://www3.telus.net/public/robark/Fl_TeacherTool/
C++ GUI tutorial http://www3.telus.net/public/robark/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]