Guest_imported
New member
- Jan 1, 1970
- 0
This is an old lab problem that I've never figured out and I give up. I've lost enough sleep over it.
For every file in the current directory, print the owners "Real World name" (in /etc/passwd/(field 5)).
I've come very close using a "for" command... ex.
for file in `ls -l`
do
owner=`awk '{print $3}' $file` #find the owners usrname #This is where my problem is. The "for" parses
#everything in ls -l thats between spaces/tabs.
realname=`grep $owner /etc/passwd | awk '{print $5}'`
echo "$file belongs to $realname"
done
# Am I not worthy!?
For every file in the current directory, print the owners "Real World name" (in /etc/passwd/(field 5)).
I've come very close using a "for" command... ex.
for file in `ls -l`
do
owner=`awk '{print $3}' $file` #find the owners usrname #This is where my problem is. The "for" parses
#everything in ls -l thats between spaces/tabs.
realname=`grep $owner /etc/passwd | awk '{print $5}'`
echo "$file belongs to $realname"
done
# Am I not worthy!?