24f197c5f834a4acb38fa4c7e25158ddc6b4a0c0
compute/data-munging.md
| ... | ... | @@ -3,6 +3,9 @@ |
| 3 | 3 | ### Sum a list of numbers |
| 4 | 4 | `cat list | paste -s -d+ | bc` |
| 5 | 5 | |
| 6 | +### Remove all but one trailing newlines |
|
| 7 | +`sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba' file` |
|
| 8 | + |
|
| 6 | 9 | ### Make sure a file has a trailing newline |
| 7 | 10 | `tail -c1 file | read -r _ || echo >> file` |
| 8 | 11 |