awk command
Posted: 2021-Jul-25, 12:00 pm
08 Jun 2007 09:51
miki
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.
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.
----------------------------
#2 08 Jun 2007 18:18
Simon Sheppard
It works for me !
If you just run ls -lg what does the output look like?
----------------------------
#3 20 Jun 2007 21:29
miki
this is my output for command ls -lg skuska :
-rw-r--r-- 1 duncan 0 2007-06-12 14:30 skuska
----------------------------
#4 20 Jun 2007 22:07
Simon Sheppard
Re: awk command
OK this must be a locale difference, so yes $4 would be right for you
original thread: https://ss64.org/oldforum/viewtopic.php?id=211
miki
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.
Code: Select all
ls -lg FILES | awk '{ x += $5 } ; END { print "total bytes: " x }'
----------------------------
#2 08 Jun 2007 18:18
Simon Sheppard
It works for me !
If you just run ls -lg what does the output look like?
Code: Select all
--col1----col2--col3--col4---col5--col6--etc
-rw-r--r-- 1 simon simon 18365 28 Aug 2006 list.txt
#3 20 Jun 2007 21:29
miki
this is my output for command ls -lg skuska :
-rw-r--r-- 1 duncan 0 2007-06-12 14:30 skuska
----------------------------
#4 20 Jun 2007 22:07
Simon Sheppard
Re: awk command
OK this must be a locale difference, so yes $4 would be right for you
original thread: https://ss64.org/oldforum/viewtopic.php?id=211