Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

re: parsing out data

Status
Not open for further replies.

thutmose

MIS
Mar 31, 2002
24
US
Hey,


Guys I am writing a script thats more like the du -k command.

ls -l | grep '^d' | awk '{print $9, $5, $3}'


my output is


size file name LOGON name

00 anyfile anyuser
123 awkscript anyuser
87 beber anyuser
7646 something anyuser


Is it a way to get the 3rd column to display the users real name rather than his logon ID.
 
Replace your awk progam with:
Code:
BEGIN{
  FS=":"
  while ((getline < &quot;/etc/passwd&quot;) > 0) { usr[$1] = $5}
  FS=&quot; &quot;
}
{print $9, $5, usr[$3]}
Hope this helps. CaKiwi
 
Hey,


thanks and I was wondering where I can get some well documented shell and awk scripts.
 
There is an awk forum here with many awk solutions to problems, although they are not generally well documented. CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top