On Mon, Mar 04, 2013 at 12:57:05PM +0100, Otto Moerbeek wrote: | On Mon, Mar 04, 2013 at 12:54:49PM +0100, Paul de Weerd wrote: | | > On Mon, Mar 04, 2013 at 12:32:32PM +0100, Paolo Aglialoro wrote: | > | Great one! | > | How to put that nice expression into an alias without console complaining | > | when executed? | > | | > | | > | # ls -l | awk '{ SUM += $5 } END { print SUM }' | > | 569047 | > | | > | # alias tot="ls -l | awk '{ SUM += $5 } END { print SUM }'" | > | # tot | > | awk: syntax error at source line 1 | > | context is | > | { SUM += >>> } <<< | > | awk: illegal statement at source line 1 | > | > Escape the "$" in the awk expression: | > | > [weerd@despair] $ alias tot="ls -l | awk '{SUM+=\$5} END {print SUM}'" | > [weerd@despair] $ tot | > 207777 | > | > I still wonder why people want to know this (seemingly useless) value. | > What does it even mean ? | > | > [weerd@despair] $ mkdir /tmp/test | > [weerd@despair] $ cd /tmp/test | > [weerd@despair] $ dd if=/dev/zero of=a bs=1024 seek=2048 count=1 | > 1+0 records in | > 1+0 records out | > 1024 bytes transferred in 0.000 secs (34133333 bytes/sec) | > [weerd@despair] $ ln a b | > [weerd@despair] $ ls -l | > total 128 | > -rw-r--r-- 2 weerd wheel 2098176 Mar 4 12:49 a | > -rw-r--r-- 2 weerd wheel 2098176 Mar 4 12:49 b | > [weerd@despair] $ tot | > 4196352 | > [weerd@despair] $ du -csh a b | > 32.0K a | > 32.0K total | > | > | > (note the lie ls(1) spreads here) | > | > | Btw, for higher readability, it would also be great to put periods in the | > | resulting output like: 1.264.691 | > | > Well, that should be easy enough to add yourself :) Left as an | > exercise to the reader... | > | > Cheers, | > | > Paul 'WEiRD' de Weerd | | But remember, file size and disk usage are two different things,
Exactly! So what is the point in summing up the sizes of a bunch of files ? I am 197 cm tall, my house number is 34, my zipcode is 1318, I have 2 brothers and 1 sister .. sum is 1552. Great, but now what ? This total value does not correspond to anything tangible (as far as I can see, at least .. hence me asking). It's no indication of how much storage space is needed to store these files, it's no indication of how large an archive would be containing these files, it's of no real use (again, afaics) except for knowing what the filesize would be of cat * > /tmp/newfile (which would be pointless in most cases I guess). Why do people care ? Paul 'WEiRD' de Weerd -- >++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+ +++++++++++>-]<.>++[<------------>-]<+.--------------.[-] http://www.weirdnet.nl/