You are not logged in.

#1 08 Jun 2007 09:51

miki
Member
Registered: 08 Jun 2007
Posts: 2

awk command

Hello,

I'am new to linux. I was looking on the bash commands and in one example of awk I think there is an error.

This program prints the total number of bytes used by FILES.

ls -lg FILES | awk '{ x += $5 } ; END { print "total bytes: " x }'

It was showing me lenght of 2007 bytes for a file. But it's an year and I think it should be $4 instead of $5.

Offline

#2 08 Jun 2007 18:18

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: awk command

It works for me !

If you just run ls -lg what does the output look like?

--col1----col2--col3--col4---col5--col6--etc
-rw-r--r--   1 simon  simon  18365 28 Aug  2006 list.txt

Offline

#3 20 Jun 2007 21:29

miki
Member
Registered: 08 Jun 2007
Posts: 2

Re: awk command

this is my output for command ls -lg skuska :

-rw-r--r-- 1 duncan 0 2007-06-12 14:30 skuska

Offline

#4 20 Jun 2007 22:07

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: awk command

OK this must be a locale difference, so yes $4 would be right for you

Offline

Board footer

Powered by