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

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 :smiley: (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...)

#! /bin/sh
while read username; do
  finger ${username}
done < inputfile > outputfile
exit 0

Cheers
ZB

:slight_smile: 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 :D)

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 :frowning:

echo "10MB /home/test/username"|awk -F"/" '{print $NF}'