LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-24-2004, 02:47 AM   #1
VisionZ
Member
 
Registered: Mar 2004
Posts: 58

Rep: Reputation: 15
Question 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 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???
 
Old 03-24-2004, 03:39 AM   #2
Demonbane
Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
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.
 
Old 03-24-2004, 03:45 AM   #3
Looking_Lost
Senior Member
 
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120

Rep: Reputation: 45
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

Last edited by Looking_Lost; 03-24-2004 at 03:47 AM.
 
Old 03-24-2004, 04:35 AM   #4
VisionZ
Member
 
Registered: Mar 2004
Posts: 58

Original Poster
Rep: Reputation: 15
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
 
Old 03-24-2004, 04:42 AM   #5
VisionZ
Member
 
Registered: Mar 2004
Posts: 58

Original Poster
Rep: Reputation: 15
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.
 
Old 03-24-2004, 04:52 AM   #6
Demonbane
Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
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
 
Old 03-24-2004, 05:07 AM   #7
VisionZ
Member
 
Registered: Mar 2004
Posts: 58

Original Poster
Rep: Reputation: 15
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??
 
Old 03-24-2004, 05:24 AM   #8
Demonbane
Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
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'
 
Old 03-24-2004, 06:17 AM   #9
VisionZ
Member
 
Registered: Mar 2004
Posts: 58

Original Poster
Rep: Reputation: 15
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?
 
Old 03-24-2004, 06:24 AM   #10
Demonbane
Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
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

Last edited by Demonbane; 03-24-2004 at 06:33 AM.
 
Old 03-24-2004, 06:34 AM   #11
VisionZ
Member
 
Registered: Mar 2004
Posts: 58

Original Poster
Rep: Reputation: 15
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
 
Old 03-24-2004, 06:39 AM   #12
Demonbane
Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
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
 
Old 03-24-2004, 06:40 AM   #13
VisionZ
Member
 
Registered: Mar 2004
Posts: 58

Original Poster
Rep: Reputation: 15
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.
 
Old 03-24-2004, 06:57 AM   #14
VisionZ
Member
 
Registered: Mar 2004
Posts: 58

Original Poster
Rep: Reputation: 15
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?
 
Old 03-24-2004, 06:59 AM   #15
Demonbane
Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
yea just change

rm -rvi *

to

rm -rvf *
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with writing a script jedimastermopar Linux - General 10 05-02-2005 01:34 PM
help writing script willinusf Programming 7 07-20-2004 11:37 AM
Help Writing a script. teeth44 Programming 2 10-14-2003 12:00 PM
Writing a Script Nyc0n Linux - General 2 05-27-2002 07:21 PM
writing a Script spanky5125 Linux - Security 5 01-08-2002 09:22 AM


All times are GMT -5. The time now is 01:25 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration