Last active
January 10, 2017 21:31
-
-
Save sloanlance/a8d530fd67999bfb7d4416322152c0cc to your computer and use it in GitHub Desktop.
BASH: Total a list of numbers
This file contains hidden or 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
#!/bin/sh -- | |
# Read numbers from stdin, one per line, | |
# concatenate them with the addition operator between them, | |
# and add them together with bc | |
paste -sd+ - | bc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment