Skip to content

Instantly share code, notes, and snippets.

@sloanlance
Last active January 10, 2017 21:31
Show Gist options
  • Save sloanlance/a8d530fd67999bfb7d4416322152c0cc to your computer and use it in GitHub Desktop.
Save sloanlance/a8d530fd67999bfb7d4416322152c0cc to your computer and use it in GitHub Desktop.
BASH: Total a list of numbers
#!/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