Skip to content

Instantly share code, notes, and snippets.

@hackingbutlegal
Last active November 11, 2016 17:09
Show Gist options
  • Save hackingbutlegal/3dc8e224b219b4642e4b020ceaffa577 to your computer and use it in GitHub Desktop.
Save hackingbutlegal/3dc8e224b219b4642e4b020ceaffa577 to your computer and use it in GitHub Desktop.
Generate html file from a directory of files. Usage: ./dir2html.sh [path to dir] > index.html
#!/bin/bash
# usage: dir2html.sh [dir] > index.html
INDEX=`ls -1 $1 | sed "s/^.*/ <li\>\<a\ href=\"&\"\>&\<\\/a\>\<\\/li\>/"`
echo "<html>
<head><title>Index of $1</title></head>
<body>
<h2>Index of $1</h2>
<hr>
<ui>
$INDEX
<ui>
</body>
</html>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment