LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-08-2013, 09:02 AM   #1
loadedmind
Member
 
Registered: Sep 2003
Location: Texas
Distribution: Red Hat/CentOS
Posts: 302
Blog Entries: 4

Rep: Reputation: Disabled
Script to empty Trash for all users


Hello all. Our environment consists of Red Hat (mixed 5.X & 6.X) with an LDAP server (CLI-only).

I realize this may come as a shock to you other systems administrators, but we're finding that our users are having issues with cleanup. /sarcasm

Particularly, the .Trash for each user gets significantly huge with the Matlab and other software that ends up taking too much space.

I'm thinking a "for i in $(cat /home/<user>/.local/Trash/*); do rm $i; done" would work, but I'm not quite sure how to substitute <user> for a variable to catch all of them.

Any/all feedback is hugely appreciated.
 
Old 11-08-2013, 03:14 PM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
rm /home/*/.local/Trash/*

Maybe use ls first to see if it really does what you want?
 
1 members found this post helpful.
Old 11-08-2013, 04:51 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
And, if I may say, there might be a human politics issue here.

People "(sometimes ...) (sometimes r-e-a-l-l-y ... trust me on this!) don't like for you to" ...

... 'solve' their 'problems' for them. (Just sayin' ...)

Ready for a "blast from the video past" that ... (ga-a-a-a-ack!! I actually remember???) http://www.youtube.com/watch?v=LLrTPrp-fW8

... yeah, it's not 'nice' to fool a ((s)he's tenured, you're not ...) researcher," either.

(Just sayin' ...)
 
Old 11-13-2013, 10:24 AM   #4
loadedmind
Member
 
Registered: Sep 2003
Location: Texas
Distribution: Red Hat/CentOS
Posts: 302

Original Poster
Blog Entries: 4

Rep: Reputation: Disabled
Thanks for the suggestions thus far. I'm looking for something a bit more fool-proof where a user variable would allow the script to remove trash for all users. Perhaps something where it first does a check for the username in /home/, then based on the output, would rm the trash.
 
Old 11-13-2013, 10:43 AM   #5
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
do you want to parse the first column of /etc/passwd ?
 
Old 11-13-2013, 12:13 PM   #6
loadedmind
Member
 
Registered: Sep 2003
Location: Texas
Distribution: Red Hat/CentOS
Posts: 302

Original Poster
Blog Entries: 4

Rep: Reputation: Disabled
Perhaps that along with a check for a uid above 500.
 
  


Reply



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
Cannot empty trash Lawrence ynt Linux - Newbie 3 09-28-2009 07:00 AM
How to open the trash folder and empty the trash in command line cmx08 Linux - Newbie 5 08-29-2008 09:15 AM
Can't empty the trash. MooseMagnet Linux - Newbie 29 12-21-2007 09:49 AM
Move to trash works beautifully, but empty trash .. different story. kd5eax Mandriva 2 12-04-2007 02:52 PM
empty trash Moleman Linux - Software 1 05-16-2003 12:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:30 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