text to html

George Davidovich freebsd at optimis.net
Sat Jul 3 14:06:37 UTC 2010


On Sat, Jul 03, 2010 at 11:07:29AM +0200, Jozsi Avadkan wrote:
> input:
> http://pastebin.com/raw.php?i=MqPXZwc3
> 
> output:
> http://pastebin.com/raw.php?i=8QCkp4yv
> 
> it will be a long day.. :D
> 
> could someone please help with it?
> 
> i have to make a "one liner" that get's the input, and gives the
> mentioned output.

A one-liner, huh?  LOL.  Add semi-colons?

The following should accomplish what you want.

#!/bin/sh

sample_data="\
debian/hosts/hosts.html
debian/use-other-users-when-using-wine-eg-dude.html
debian/java-chromium-etc.html
dns/dns-server-szakszon-mihaly-hungarian.html
netbsd/sshd.html
netbsd/installing-removing-programs.html
netbsd/install-from-pendrive/install-from-pendrive.html
openwrt/wrt160nl/wrt160nl-flash.html
routeros/home-soho-router.html
routeros/turn-off-watchdog.html"

seen='nothing_to_see_yet_move_along'

echo "$sample_data" | while read target; do

	topic=${target%%/*}     # debian/hosts/hosts.html -> debian
	filename=${target##*/}  # debian/hosts/hosts.html -> hosts.html
	title=${filename%.*}    #              hosts.html -> hosts

	if [ $topic = $seen ]; then
		echo "    | <a href=\"${target}\">${title}</a>"
	else
		echo "<br> <br> <font size=4>${topic}</font> <br>"
		echo "    <a href=\"${target}\">${title}</a>"
	fi

	seen=$topic

done

-- 
George


More information about the freebsd-questions mailing list