Last active
May 16, 2021 20:23
-
-
Save dspinellis/e0cd63da39eb9346445495c9956d852e to your computer and use it in GitHub Desktop.
Filter to add decimal separators to long numbers
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
#!/bin/sed -Ef | |
# | |
# Add a LaTeX thin space (\,) decimal separator to long digit sequences | |
# | |
# Diomidis Spinellis, October 2018 | |
# | |
# Save this as a file and add it to your path, or run at as a one-liner: | |
# sed -E ':a;s/([0-9])([0-9]{3})([^0-9]|$)/\1\\,\2\3/g;ta' | |
# | |
:a | |
# Add a , after a digit followed by three digits followed by non-digit or EOL | |
s/([0-9])([0-9]{3})([^0-9]|$)/\1\\,\2\3/ | |
# Try the replacement again if the replacement succeeded | |
ta |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment