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 |
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. |
Quote:
Code:
find /home -name ".thumbnails" -exec rm -rf {} \; not under home but in some strange location), in which case you could just go Code:
awk -F: '$3 > 99 {print $6}' /etc/passwd Cheers, Tink |
awk -F: '$3 > 99 {print $6}' /etc/passwd
what is "'$3 > 99" ?? |
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 |
i like this one -
find /home -name ".thumbnails" -exec rm -rf {} \; |
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 |
wanna learn commands
|
Good enough reason, I guess. And: good on yah! :)
Cheers, Tink |
i try to delete files not accessed for 7 or more days
|
Code:
find /home/ -atime +7 -type f -regex ".+\/.thumbnails/.+" -exec rm {} \; Cheers, Tink |
+\/.thumbnails/.+" means include path??
|
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 |
combined these two
rm -rf /home/*/.thumbnails find /home -name ".thumbnails" -exec rm -rf {} \; find /home/*/.thumbnails -atime +7 -type f -exec rm -rf {} \; |
All times are GMT -5. The time now is 02:56 AM. |