LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 01-16-2003, 02:00 PM   #1
Tingle
LQ Newbie
 
Registered: Jan 2003
Posts: 3

Rep: Reputation: 0
Deleting files


Hi,

I apologise for the simple question (but the title does say where newbies come for help!)

I want to delete all the contents in a folder bar one called index.html however, they are all write protected so it asks me to confirm each one

Is there a way to force it to delete them?

I need to make a cron script to clean out a directory but the files inside are read only basically

Thanks in advance
 
Old 01-16-2003, 02:06 PM   #2
iceman47
Senior Member
 
Registered: Oct 2002
Location: Belgium
Distribution: Debian, Free/OpenBSD
Posts: 1,123

Rep: Reputation: 47
The manpage (man rm) says:

-f, --force
ignore nonexistent files, never prompt
 
Old 01-16-2003, 02:34 PM   #3
Tingle
LQ Newbie
 
Registered: Jan 2003
Posts: 3

Original Poster
Rep: Reputation: 0
how about telling it to remove all the files in the directory apart from index.html? (without removing the directory itself, or those within)

Thanks
 
Old 01-16-2003, 04:16 PM   #4
iceman47
Senior Member
 
Registered: Oct 2002
Location: Belgium
Distribution: Debian, Free/OpenBSD
Posts: 1,123

Rep: Reputation: 47
Can't think of something how to do that right now, except for:
(this is an ugly workaround, but it'll work)
Code:
#!/bin/bash
mv /home/Tingle/foo/index.html /tmp/
rm -f /home/Tingle/foo/*
mv /tmp/index.html /home/Tingle/foo/
where foo is the name of the directory you want to have everything cleaned except index.html.
[edit: typo in code]

Last edited by iceman47; 01-16-2003 at 04:20 PM.
 
Old 01-16-2003, 04:19 PM   #5
Tingle
LQ Newbie
 
Registered: Jan 2003
Posts: 3

Original Poster
Rep: Reputation: 0
Managed to find an alternative solution:

remove the directory with everything in it, readd it, chmod the new one, then untar a file containing the index.html in the appropriate directories

It works ok so that should do
 
  


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
Deleting files in C monil Programming 4 03-13-2005 10:33 AM
Deleting files! a_priebe47 Slackware 6 10-17-2004 09:58 PM
How to keep people from deleting certain files? vincebs Linux - Newbie 9 04-12-2004 02:40 PM
deleting recent files Santas Linux - General 2 01-19-2004 06:26 AM
Deleting files ShakyJake Linux - Newbie 12 05-08-2003 03:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:10 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration