Hacker News new | ask | show | jobs
by xvolter 2169 days 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"

4 comments

The 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/t...

This also strips the leading hashes + optional space:

    awk 'sub("^### ?","")' "$0"
sed -n '/^###/p' is cross-platform friendly.
This will also work:

  sed '/^###/!d'
This will also work:

   sed '/^#\{3\}/!d'
Nice, this is much cleaner