We help IT Professionals succeed at work.

Shell script to finger every users

clo1
clo1 asked
on
Medium Priority
520 Views
Last Modified: 2013-12-26
How to write a sh shell script to finger every users(including root, nobody, nobodyV, daemon, bin,.....) in the passwd file ONCE !!!
Comment
Watch Question

ozo
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015

Commented:
for user in `cut -f1 -d: /etc/passwd` ;do
finger $user
done

Author

Commented:
If I do cat /etc/passwd | wc -l I can get 142 from the command. But if I run the script that ozo given to me. And I will get 146. See what's the different. So there maybe have some duplicated user name
ozo
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015

Commented:
Or finger may have returned more than one line for some users
maybe you want
finger -sbqpfhm $user

Author

Commented:
Actually just -m option is good enough for my answer !
Commented:
Hi,

   A simple
     
     cat /etc/passwd | awk -F ':' '{print $1}' | xargs finger

would do.

Regards,
Minh Lai

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.