Skip to content

Instantly share code, notes, and snippets.

@bichotll
Last active August 29, 2015 14:02
Show Gist options
  • Save bichotll/936bc8e9114d01f1af92 to your computer and use it in GitHub Desktop.
Save bichotll/936bc8e9114d01f1af92 to your computer and use it in GitHub Desktop.
Add directory at Home.md (for Wikis)
#create rutes
tree -fi | sed -r 's/\.\/|.md//g' | tail -n +2 | \
while read CMD; do
echo '['$CMD']('$CMD')'
echo ''
done > list-files.md
#check the file length
numberLines=$(cat list-files.md | wc -l)
#remove the last not real link
sed -i $numberLines's/(.*)//' list-files.md
#remove the last line but one
numberLines=`expr $numberLines - 1`
sed -i $numberLines's/.*/\n/' list-files.md
#add result to Home.md
numberLines=$(cat Home.md | wc -l)
lineListPages=$(grep '#List pages' Home.md -ns | sed 's/:.*//g')
#if lineListPages does not exist
if ! [ -z "$lineListPages" ]
then
sed $lineListPages','$numberLines'd' Home.md -i
fi
echo '#List pages' >> Home.md
echo '' >> Home.md
cat list-files.md >> Home.md
#execute list-files to create index on Home.md
./list-files.sh
#git
git status
echo ''
echo ''
echo 'Press enter to continue'
read
git add .
git commit --all
git push --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment