Created
November 18, 2022 08:30
-
-
Save juanmsl/aca0caf626c53e36c3f9f33209a58569 to your computer and use it in GitHub Desktop.
This file contains 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 -e | |
echo "usage: $0 <txt file containing list of urls>" | |
inputFile=${1} | |
if [ $# -ne 1 ] || [ ! -f ${inputFile} ];then | |
echo 'check usage' | |
exit -1 | |
fi | |
outputFile='bookmarks.html' | |
echo '<DL>' > $outputFile | |
NumLines=`wc -l ${inputFile} | cut -d' ' -f5` | |
currLineNum=0 | |
inGroup="no" | |
for eachUrl in `cat ${inputFile}` | |
do | |
let currLineNum=${currLineNum}+1 | |
urlTitle=`echo ${eachUrl} | rev | cut -d'/' -f1 | rev` | |
if [ -z ${urlTitle} ] || ([[ ${urlTitle} =~ "www" ]] && [[ ${urlTitle} =~ "com" ]]);then | |
urlTitle=`echo $eachUrl | cut -d'.' -f2` | |
echo " <DT><A HREF=\"${eachUrl}\">${urlTitle}</A>" >> $outputFile | |
else | |
echo "${urlTitle} (${currLineNum}/${NumLines})" | |
if [[ ${inGroup} == "no" ]]; then | |
inGroup="yes" | |
else | |
echo " </DL>" >> $outputFile | |
fi | |
echo " <DT><H3>${urlTitle}</H3>" >> $outputFile | |
echo " <DL>" >> $outputFile | |
fi | |
done | |
if [[ ${inGroup} == "yes" ]]; then | |
echo ' </DL>' >> $outputFile | |
fi | |
echo '</DL>' >> $outputFile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment