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.
Use php or some other html-friendly scripting language... Should be easy. - Jussi On 3.7.2010 12.07, 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. > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos >-- Jussi Hirvi * Green Spot Topeliuksenkatu 15 C * 00250 Helsinki * Finland Tel. +358 9 493 981 * Mobile +358 40 771 2098 (only sms) jussi.hirvi at greenspot.fi * http://www.greenspot.fi
On 7/3/10, Jozsi Avadkan <jozsi.avadkan at gmail.com> 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.Definitely looks like a job for a script and personally I'll go with PHP due to familiarity. read line by line, explode the string on /, then section off based on the first token.
On 07/03/2010 02:07 AM, 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. >Why a 'one liner'? That sounds an awful lot like homework...But I'll give you the benefit of the doubt. You can turn this Perl script into a one liner easily. Or you can just save it as a script and use it like: ./convert-to-html.pl < input_data.txt #!/usr/bin/perl use strict; use warnings; my (%section_info, @section_list); while(<STDIN>) { s/^\s+//s; s/\s+$//; next unless ($_ ne ''); s/&/\&/gs; s/</\</gs; s/>/\>/gs; s/"/\"/gs; my ($dir,$file) = m#(^[^/]+)/(.+)$#; $file =~ s/\.html$//i; push(@{$section_info{$dir}}, "<a href=\"$_\">$file</a>"); push(@section_list, $dir); } foreach my $section (@section_list) { print "<br><font size=4>$section</font><br>\n"; print join(" |\n", @{$section_info{$section}}); print "\n<br>\n"; } -- Benjamin Franz
my own solution: http://pastebin.com/raw.php?i=kqQXCpD5> 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. >
From: Jozsi Avadkan <jozsi.avadkan at gmail.com>> input: http://pastebin.com/raw.php?i=MqPXZwc3 > output: http://pastebin.com/raw.php?i=8QCkp4yv > i have to make a "one liner" that get's the input, > and gives the mentioned output.Here's my one line: awk -F/ ' { if (p != $1) { p=$1; print "<br>\n<br><font size=4>"$1"</font><br>"; } split($2, a, /\./); t=a[1]; print "<a href=\""$0"\">"t"</a>"; } ' <MYFILE> JD