Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding thru List 3

Status
Not open for further replies.

Mag0007

MIS
Feb 15, 2005
829
US
I have a list of home directories, example:
/home/user1
/home/user2
/home/user3
up to /home/user778


I would like to see if .netrc exists in these directories.


 
A starting point:
for d in /home/user*
do [ -f $d/.netrc ] || echo Missing .netrc in $d
done

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Sorry - just noticed the 'list' bit!! That said, why use a list when you can do it dynamically?
 
Well, its not always going to be /home

I am using another script to get my $HOME directories. There are some users for example root where its $HOME=/

 
for d in `cat my_list`
and continue like PHV suggested
 
Yet another way:
while read d
do [ -f $d/.netrc ] || echo Missing .netrc in $d
done < /path/to/list

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for the quick replies!!!!

I got it.


thank you!





 
Good. It does seem a little like reinventing the wheel however. Even if some $HOMEs are not under /home, a find / -name '.netrc' would tell you them anyway. Still, each to his own!
 
Ken:
Hmm, you are saying just search the entire filesystem '/' for .netrc ?

Isn't .netrc initiated thru user's $HOME? Therefore I am only looking only $HOME. Also, searching thru '/' would take hours on a system with 200 users with over 1TB of space :)

Any suggestions?


 
I take your point (and I wasn't trying to invalidate your methodology, so apologies if I gave that impression), but running the find in the background when nothing much else is happening would probably be an option. Always assuming, of course, that you have such a window available.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top