INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Script output to file

Script output to file

(OP)

I use the command: finger `sort /etc/passwd | cut -f1 -d":"` | grep -i log > /userlist.txt

This outputs to the file userlists.txt information as follows:

Login name: XXXXXXXX
Never logged in.
Login name: XXXXXXXX
Last login Mon Mar 7, 2011 on pts/31 from
Login name: XXXXXXX
Last login Mon Aug 12 08:40 on pts/6 from XXX.XXX.XXX.XXX
Login name: XXXXXXXX
Last login Wed Sep 4 21:28 on pts/4 from XXX.XXX.XXX.XXX

I want to put this into a script that I can execute instead of having to enter the command every time (or copy and paste it)

However, when I put this in a script and execute it, it only provides and output of the sorted passwd file on the screen and doesn't write to the file.

So I get this on the screen and nothing else:

root 0 root 0 Super-User
root2 0 root 0 Super-User
daemon 1 other 1
bin 2 bin 2
sys 3 sys 3
adm 4 adm 4 Admin

etc, etc, etc.....

How can I get the command to run correctly and output to the file in a script?

- Stinney
"Scire ubi aliquid invenire possis, ea demum maxima pars eruditionis est"

"To know where to find anything is, after all, the greatest part of education"

RE: Script output to file


Define an alias and just type the command:

CODE

alias ulst="sort /etc/passwd |cut -d':' -f1|xargs finger|grep '^Log' >./userlist.txt" 
3eyes

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

RE: Script output to file

(OP)

Sweeeeeet. Thanks!

- Stinney
"Scire ubi aliquid invenire possis, ea demum maxima pars eruditionis est"

"To know where to find anything is, after all, the greatest part of education"

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close