Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: printing out users without home directories

by syphilis (Archbishop)
on May 16, 2018 at 02:47 UTC ( [id://1214602]=note: print w/replies, xml ) Need Help??


in reply to printing out users without home directories

This allows me to put all users into an array called @passwd_entries. How do I print out all users without /home directories?

for(@passwd_entries) { print "/home/$_ does not exist\n" unless -d "/home/$_"; }
See -X and perlsyn.

(Fixed a couple of typos in updates.)

Cheers,
Rob

Replies are listed 'Best First'.
Re^2: printing out users without home directories
by haukex (Archbishop) on May 16, 2018 at 06:31 UTC
    for(@passwd_entries) { print "/home/$_ ...

    In the context of the code from the root node, that won't work, since $_ contains the entire line from the entry.

      ... that won't work, since $_ contains the entire line from the entry

      Yes, the wording of the OP's initial post led me to believe that his @passwd_entries contained nothing but a list of the usernames - though, of course, the OP didn't exactly specify that was the case.

      Cheers,
      Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1214602]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-26 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found