Skip to content

Instantly share code, notes, and snippets.

@ychaouche
Last active July 15, 2025 11:05
Show Gist options
  • Save ychaouche/93701b3149b4571edd72793c3e822d73 to your computer and use it in GitHub Desktop.
Save ychaouche/93701b3149b4571edd72793c3e822d73 to your computer and use it in GitHub Desktop.
Display headers from an outlined document
#!/bin/bash -i
# we need debug
file="$1"
sublevels=1
postprocess=cat
for arg
do
case "$arg" in
-[1-9])
sublevels=${arg:1}
;;
-n)
postprocess=nl
;;
esac
done
debug grep -E "^\*{1,$sublevels} " "$file"
grep -E "^\*{1,$sublevels} " "$file" | "$postprocess"
12:04:24 ~/NOTES/TXT -1- $ txt.headers linux.info -3 -n | head -20
debug: grep -E ^\*{1,3} linux.info
1 * linux memory / swapiness
2 * Linux distros
3 ** Voir également
4 ** Distros linux utilisées
5 ** NuTyX
6 ** deepin linux
7 ** bedrock linux
8 ** comment savoir ce que c'est comme distro
9 ** composants
10 *** installer
11 *** package manager
12 *** init system
13 *** desktop
14 *** pre-selection of software
15 ** rolling releases
16 ** linux distros for phones
17 * DM pour linux
18 * virtualization software for linux hosts
19 * KDE
20 ** apps
12:04:42 ~/NOTES/TXT -1- $ txt.headers linux.info -2 -n | head -20
debug: grep -E ^\*{1,2} linux.info
1 * linux memory / swapiness
2 * Linux distros
3 ** Voir également
4 ** Distros linux utilisées
5 ** NuTyX
6 ** deepin linux
7 ** bedrock linux
8 ** comment savoir ce que c'est comme distro
9 ** composants
10 ** rolling releases
11 ** linux distros for phones
12 * DM pour linux
13 * virtualization software for linux hosts
14 * KDE
15 ** apps
16 ** core components
17 ** why I like KDE
18 ** how to get the version of KDE
19 ** config directory + config files
20 ** logfiles
12:04:53 ~/NOTES/TXT -1- $
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment