Skip to content

Instantly share code, notes, and snippets.

@fukamachi
Created August 27, 2013 00:09
Show Gist options
  • Save fukamachi/6348230 to your computer and use it in GitHub Desktop.
Save fukamachi/6348230 to your computer and use it in GitHub Desktop.
A small Common Lisp program to sum up file sizes from `ls -l`.
;; https://twitter.com/potix2/status/371962749246394368
;; Usage
;; $ ls -l | shly sumsize
(ql:quickload :cl-ppcre)
(defun sumsize ()
(loop with sum = 0
for line = (read-line *standard-input* nil)
while line
for size = (nth 3 (ppcre:split "\\s+" line))
when (stringp size)
do (incf sum (parse-integer size))
finally (return sum)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment