4 ms·
I also posted to the github gist, this the sed command here is not cross-plataform friendly. You can accomplish the same thing with an awk command though: awk
by xvolter 6y ago
I also posted to the github gist, this the sed command here is not cross-plataform friendly. You can accomplish the same thing with an awk command though:
awk '/^###/' "$0"
- jpxw 6y agoNice, this is much cleaner
- pwdisswordfish2 6y agosed -n '/^###/p' is cross-platform friendly.
- u801e 6y agoThis will also work: sed '/^###/!d'
- pwdisswordfish2 6y agoThis will also work: sed '/^#\{3\}/!d'
- yesenadam 6y agoThis also strips the leading hashes + optional space: awk 'sub("^### ?","")' "$0"
- ddevault 6y agoThe bit at the end isn't POSIX sh, either. Fixed version: if [ $# -eq 0 ] || [ "$1" = "-h" ]; then help exit 1 fi Relevant spec bits: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/t...