LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 06-26-2008, 05:03 PM   #1
Beresford
LQ Newbie
 
Registered: Oct 2004
Location: New Zealand
Posts: 28

Rep: Reputation: 15
Delete multiple hidden files [SOLVED]


Is there a way to delete multiple hidden files in a directory. I only want to delete the hidden files, not the normal files.

I can list them, and delete them one at a time, but when there are 20 files I need to delete, then it's a waste of time.

Thank you in advance.

Last edited by Beresford; 06-26-2008 at 07:57 PM. Reason: answer received
 
Old 06-26-2008, 06:01 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950
Assuming the files all start with a leading '.', and that you want to remove all dotted files from the current directory and you aren't concerned with any subdirectories or other fancy stuff, it should be as s a simple as using a * wildcard. Just run
Code:
rm -i .*
Note that I added the -i flag that makes rm interactive, which is a usually good idea to use in case it tries to remove any files you want to keep.
 
Old 06-26-2008, 07:56 PM   #3
Beresford
LQ Newbie
 
Registered: Oct 2004
Location: New Zealand
Posts: 28

Original Poster
Rep: Reputation: 15
Sweet, that's exactly what I wanted. Thank you, you've just saved me many hours of typing
 
Old 06-27-2008, 10:44 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950
No problem. The bash command line is very powerful and flexible. For a good primer on shell commands and scripting I highly recommend LinuxCommand.org.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I write a script using sed to delete the first and last line in multiple files Rikki D Programming 4 05-03-2008 12:01 AM
Delete a single E-mail / multiple mbox files mgichoga Debian 0 02-18-2007 09:42 PM
How to delete hidden files??? kabucek Linux - Distributions 5 08-28-2006 12:21 AM
delete multiple files ashley75 Linux - General 1 05-02-2006 02:32 PM
Handling multiple forms with same name hidden fields coolman0stress Programming 5 09-04-2003 02:34 PM


All times are GMT -5. The time now is 05:25 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration