Created
August 27, 2013 00:09
-
-
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`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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