LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to delete all files in one command for all user (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-delete-all-files-in-one-command-for-all-user-546407/)

packets 04-16-2007 03:08 AM

how to delete all files in one command for all user
 
Hi to all.

I setup Mailserver with spamassassin using Maildir format. I want to delete all files under .junkmail dir. The thing is all user has .junkmail dir and i manually delete all the contents per user. Is there a way where I can delete all the files in all directories of .junkmail in all user without doing it maunally?


TIA :)

avallach 04-16-2007 03:14 AM

I never tried it but rm /home/*/.junkmail should work

packets 04-16-2007 03:43 AM

hahahaha why didn't I think of that. Such an idiot I am.

Thx!!!!

Junior Hacker 04-16-2007 08:32 PM

If I read your post correctly, .junkmail ia a directory and you want to remove all files in that directory for all users without removing the directory itself. The command suggested above will not work. Change into the /home directory and issue this command:
Code:

[root@localhost home]# find ./*/.junkmail -type f -exec rm -fr {} \;
Always run a test of any command suggested in forums, /opt is usually empty, create temporary user folders in /opt with a couple sub folders containing files. Issue this command to remove all files in only one of the sub folders to verify it.

dugas 04-16-2007 08:56 PM

almost
 
avallach was just missing an asterik
Code:

rm -f /home/*/.junkmail/*


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