The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell script to search for text in a file and copy file imeadows UNIX for Dummies Questions & Answers 9 2 Weeks Ago 06:12 PM
Shell script for text extraction from a file vignesh53 Shell Programming and Scripting 3 02-05-2008 05:16 AM
Looking for command(s)/ script to find a text string within a file wrwelden Shell Programming and Scripting 5 11-22-2006 09:53 PM
Using the Finger command in a Script apolishuk Shell Programming and Scripting 4 12-02-2003 11:42 AM
redirecting username to finger dhinojosa UNIX for Dummies Questions & Answers 2 02-06-2002 09:11 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-07-2005
Registered User
 

Join Date: Jul 2003
Posts: 12
How to input username on text file into finger command on shell script

I'm trying to clean up my server and I have the list of some "special" users stored on the text file like this

Quote:
abcd
defg
kndad
daodi
Now I want to write a shell script to finger all of them so I can have some kind of ideas who they are but here comes the problem....I completely forgot how to do it with shell script (it has been such a long time since I wrote one anyway). Please do not tell me to do it manually since it has about 300 username on the list (gonna take forever to do it )

So I reallie appreicate if anyone here can give me some kind of advice on how to do it. I'm having problem trying to figure out how to take the username on the text file and input them into the finger command (maybe using while but hmm...)
Reply With Quote
Forum Sponsor
  #2  
Old 11-07-2005
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Code:
#! /bin/sh
while read username; do
  finger ${username}
done < inputfile > outputfile
exit 0
Cheers
ZB
Reply With Quote
  #3  
Old 11-07-2005
Registered User
 

Join Date: Jul 2003
Posts: 12
omg, this is definitely what i'm looking for....thx you so much. Here my last question (i promise I won't bothering u anymore )

When you do the "du" command, it will usualy display the result in the format like this

10MB /home/test/username

so is there anyway that I can cut the "username" from it so that I can input it into the my current finger script? I guess sed or awk would do but gosh, where is my sed & awk book

Last edited by Micz; 11-07-2005 at 10:07 PM.
Reply With Quote
  #4  
Old 11-07-2005
Registered User
 

Join Date: Sep 2005
Location: Chennai
Posts: 80
echo "10MB /home/test/username"|awk -F"/" '{print $NF}'
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 01:28 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0