Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete files

Status
Not open for further replies.

tlcscousin

Technical User
Mar 25, 2001
1,731
CA
I have a folder in /opt/psbak that contains about 40 files i want to delete. Can i just cd to the folder and rm *.*
I want to ensure i am only deleting the files in that folder and not touch anything else. I can cd into the folder but it scrolls through the files so i cannot see every file just the last screen full.
I could just remove the psbak i assume
rm -f psbak
would delete the folder. I am learning debian gradually on my test machine but have been asked to remove the files on the production machine because the admin is unavailable i do have root access.
 
Actuaslly the -f option tells rm to force the issue and don't bother giving you a prompt. The remove a folder or directory, you would use the -d option. If the desired directory has contains sub-directories, you would also use the -r option. This will delete files and directories recursively. To be able to view the entire contents of a large directory, you can use 'less'. This is very much like 'more' under dos. To get columns you would use the -C option. So the command would look like this:

ls -C | less

or

dir | less

Pressing any key will scroll down. Pressing q will quit.



 
Somebody remind me to read my posts before I submit, not after.



 
You don't have to use *.* in Linux. This is more of a Windows like syntax as Windows uses the concept of filename.fileextension. These two items are stored separately and so *.* means any filename and any file extension. Linux does not strictly speaking have this type of split. You can still have filename.fileextension but the "." is part of the file name.

So in Windows *.* means all files. In Linux it means all files with a "." anywhere in the filename.


Lee Mason
Optimal Projects Ltd
 
As a warning: .. (the parent directory) matches *.* as well. so if you do rm -rf *.* as root, you wipe everything.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
I tested the deletion by going to the /opt directory and running
rm -d -i psbak
In this way i was asked to confirm for each deletion and assume i could say no to removing the psbak folder itself.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top