LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help writing a rm script (https://www.linuxquestions.org/questions/linux-newbie-8/help-writing-a-rm-script-161695/)

VisionZ 03-24-2004 02:47 AM

Help writing a rm script
 
I was wondering how I would write a script which would remove all my temporary internet files in in my temporary internet files folder

C:\Documents and Settings\Owner\Local Settings\Temporary Internet Files
is where they are loacted

I tried writing it but cant seem to stop getting error messages]
I am a complete :newbie: to Linux, I tried:

Code:

for files in C;\Temporary Internet Files\Owner\Local Settings\Temporary Internet Files; do; rm *.*; done
obviously it didnt work

any suggestions

Also I am currently using Cygwin for windows and using the emacs editor
any other suggestions or what am I doing wrong???

Demonbane 03-24-2004 03:39 AM

Can't you just do
Code:

rm -rf /cygdrive/c/Documents\ and\ Settings/zechs/Local\ Settings/Temporary\ Internet\ Files/*
btw /cygdrive/c is where cygwin mounts C drive by default, besides is there a need to use cygwin? a simple dos batch file can do the job.

Looking_Lost 03-24-2004 03:45 AM

I'm not using cygwin so this may not be of any use -

You probably have to escape the spaces in the directory names lik

c:\Documents\ and\ Settings\Owner\Local Settings\Temporary\ Internet\ Files

why not just do

cd c:\Documents\ and\ Settings\Owner\Local Settings\Temporary\ Internet\ Files\
echo $PWD

to see if it's getting to the right directory, then change it to

rm -rf c:\Documents\ and\ Settings\Owner\Local Settings\Temporary\ Internet\ Files\*

if it is

Edit: great minds think alike :)

VisionZ 03-24-2004 04:35 AM

yeah its part of my class at school to write scripts, I thought this would be a rather easy one but info like that Demonbane such as where cyg mounts the C drive is new to me. Plus I,m a complete Newb just started learning linux

VisionZ 03-24-2004 04:42 AM

Well Neither one worked, it couldnt change the directory to that, and Demon, it just ran the dropped to me the next prompt and didnt delete the files.:(

Demonbane 03-24-2004 04:52 AM

Make sure you create a /cygdrive directory, its isnt created by default for some reason, though the mount points are.
and its not suppose to give any output unless you add a "-v" switch.
If you want to use a for loop you need a wildcard
Code:

for files in /cygdrive/c/Documents\ and\ Settings/zechs/Local\ Settings/Temporary\ Internet\ Files/*; do rm $file; done
though its kinda pointless

VisionZ 03-24-2004 05:07 AM

where do I add a -v switch we have never learned those,
also this may seem like a stupid question but do I need to make the folder like others

ie : right clicking make new folder and nameing it cygdrive??

Demonbane 03-24-2004 05:24 AM

Quote:


where do I add a -v switch we have never learned those


rm -rvf <blah blah>

Quote:


also this may seem like a stupid question but do I need to make the folder like others

ie : right clicking make new folder and nameing it cygdrive??


get in Cygwin bash prompt
Code:

mkdir /cygdrive
you c drive should automatically pop up in there as a directory called 'c'

VisionZ 03-24-2004 06:17 AM

For some readon it isnt working, let me put my code in here so you can take a look.

Code:

for files in /cygdrive/c/Documents\ and\ Settings/zechs/Local\ Settings/Temporary\ Internet\ Files/*
do
rm -rvf $file
done


I dont see whats missing

I tried it with and with out a \ after internet

since I am guessing the / is separating the directories and the \ is the for the literal character of a space between the words :)

BTW the cmd mkdir made a cygdrive folder under my main cygwin drive

/C:/cygwin/cygdrive

thats what it was supposed to do correct?
should I put the script in the cygdrive folder? then cd cygdrive and run it?

Demonbane 03-24-2004 06:24 AM

btw "zechs" is my username on my windows box, change it to yours
where the script is doesnt matter since you're using absolute path

VisionZ 03-24-2004 06:34 AM

Therefore I change zechs to Owner which appears in the upper left corner of my windows box.

After doing so same promblem, no output =P

do I need a : after c

was I correct in placing a \ after internet?
or should I have left it

internet files

instead of

Interent\ Files

Demonbane 03-24-2004 06:39 AM

yes you need the backspace, if you're doing it inside Cygwin bash
cd into
/cygdrive/c/Documents\ and\ Settings/Owner/Local\ Settings/Temporary\ Internet\ Files/
do "rm -rvi *'

and see what happens

VisionZ 03-24-2004 06:40 AM

Nevermind, disregard that owner comment, what do you mean windows box, windows is just a bunch of damn boxes, where can I find my name, such as you described.
I truly appreciate the patientence and help.

VisionZ 03-24-2004 06:57 AM

OK I see what that did duh, it then prompts me to delete the file and there is a ton!!!
Is there a way I can make it auto delete all of these, and yes it was Owner (hits himself cause its 5 in the morning)

would this script work
Code:

echo "would you like to delelte your temp internet files"
read yes

if [ $1 = yes ]
then
cd /cygdrive/c/Documents\ and\ Settings/Owner/Local\ Settings/Temporary\ Internet\ Files/

rm -rvi *

else
echo "fine let them sit thier"
exit 1

fi

Insted of prompting me how can i just make it delete all the files automatically?

Demonbane 03-24-2004 06:59 AM

yea just change

rm -rvi *

to

rm -rvf *


All times are GMT -5. The time now is 12:19 PM.