Timeline for How to remove empty lines from beginning and end of file?
Current License: CC BY-SA 4.0
3 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 19, 2021 at 20:33 | history | edited | Quasímodo | CC BY-SA 4.0 |
[a-z] would fail to catch some non-empty lines, such as ones only consisting of numbers.
|
| Nov 15, 2019 at 18:17 | comment | added | glenn jackman |
Clever. The trick here is that command substitution ($(cat file)) strips off trailing newlines. I'd offer 2 suggestions: 1) use the bash builtin $(< file) instead of cat; 2) use a here string: sed '/[^[:blank:]]/,$!d' <<< "$(<file)"
|
|
| Nov 14, 2019 at 15:57 | history | answered | schrodingerscatcuriosity | CC BY-SA 4.0 |