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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
08-17-2006, 07:01 PM
|
#1
|
|
Member
Registered: Aug 2006
Distribution: slack
Posts: 323
Rep:
|
how to list system users
how to list existing users??
i try to write a bash script to remove thumbnails from $HOME directory...
and i need a way to list users
|
|
|
|
08-17-2006, 07:14 PM
|
#2
|
|
Member
Registered: Aug 2006
Distribution: FC, Mandriva, Suse
Posts: 52
Rep:
|
Logged in users or all users?
Logged in users would be easy, not all users. Still, you could check the /etc/shadow file and retrieve the users from there.
|
|
|
|
08-17-2006, 07:26 PM
|
#3
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
|
Quote:
|
i try to write a bash script to remove thumbnails from $HOME directory...
|
Why that complicated?
Code:
find /home -name ".thumbnails" -exec rm -rf {} \;
No need to hunt for names (unless some users have their home
not under home but in some strange location), in which case you
could just go
Code:
awk -F: '$3 > 99 {print $6}' /etc/passwd
to find them ...
Cheers,
Tink
Last edited by Tinkster; 08-17-2006 at 07:27 PM.
|
|
|
|
08-17-2006, 07:34 PM
|
#4
|
|
Member
Registered: Aug 2006
Distribution: slack
Posts: 323
Original Poster
Rep:
|
awk -F: '$3 > 99 {print $6}' /etc/passwd
what is "'$3 > 99" ??
|
|
|
|
08-17-2006, 07:40 PM
|
#5
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
|
Make sure that it only lists users that are "human". In Slackware,
all system users (not people) have a UID < 100 ... may vary for
your system, have a look at /etc/passwd. But if you DON'T have people's
in other directories than home, why bother? :) Just use the find.
Or, even more easy (just thought of that now) :}
Code:
rm -rf /home/*/.thumbnails
Cheers,
Tink
|
|
|
|
08-17-2006, 07:46 PM
|
#6
|
|
Member
Registered: Aug 2006
Distribution: slack
Posts: 323
Original Poster
Rep:
|
i like this one -
find /home -name ".thumbnails" -exec rm -rf {} \;
|
|
|
|
08-17-2006, 08:26 PM
|
#7
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
|
I'm curious: why do you prefer the more I/O and CPU intense solution over
the plain one that uses shell globbing?
Cheers,
Tink
|
|
|
|
08-17-2006, 08:31 PM
|
#8
|
|
Member
Registered: Aug 2006
Distribution: slack
Posts: 323
Original Poster
Rep:
|
wanna learn commands
|
|
|
|
08-17-2006, 08:34 PM
|
#9
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
|
Good enough reason, I guess. And: good on yah!
Cheers,
Tink
|
|
|
|
08-17-2006, 08:48 PM
|
#10
|
|
Member
Registered: Aug 2006
Distribution: slack
Posts: 323
Original Poster
Rep:
|
i try to delete files not accessed for 7 or more days
|
|
|
|
08-17-2006, 08:57 PM
|
#11
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
|
Code:
find /home/ -atime +7 -type f -regex ".+\/.thumbnails/.+" -exec rm {} \;
Cheers,
Tink
|
|
|
|
08-17-2006, 09:04 PM
|
#12
|
|
Member
Registered: Aug 2006
Distribution: slack
Posts: 323
Original Poster
Rep:
|
+\/.thumbnails/.+" means include path??
|
|
|
|
08-17-2006, 10:23 PM
|
#13
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
|
It's a regular expression against which all found files (including
their path) are matched; you said you only wanted to delete files which
hadn't been accessed in a week from the .thumbnail directory of any user.
What our find does is to search for all files (-type f) under /home that
have the component /.thumbnails/ in their path (.+ means one or more character)
and that have and access time of over a week (-atime +7).
It does NOT search for a path that looks like that.
Cheers,
Tink
|
|
|
|
09-13-2006, 06:22 AM
|
#14
|
|
Member
Registered: Aug 2006
Distribution: slack
Posts: 323
Original Poster
Rep:
|
combined these two
rm -rf /home/*/.thumbnails
find /home -name ".thumbnails" -exec rm -rf {} \;
find /home/*/.thumbnails -atime +7 -type f -exec rm -rf {} \;
Last edited by ygloo; 09-13-2006 at 06:26 AM.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:44 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|