Created
November 17, 2018 09:11
-
-
Save ggirtsou/bfc8d328a0318b2f0c4f9819b4627ac4 to your computer and use it in GitHub Desktop.
Bash script that extracts HTML title tag from files and creates a table of contents. Assumes files are named {number}.html.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
END=$(ls -l | grep ".html" | wc -l) | |
START=1 | |
for (( i=$START; i<=$END; i++ )) | |
do | |
cat ./$i.html | grep -oE "<title>.*</title>" | sed 's/<title>/'"$i"'.html /' | sed 's/<\/title>//' | head -n 1; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
You might want to redirect the output to a file, for example:
./generate_table_of_contents.sh > table_of_contents.txt