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@centos.org http://lists.centos.org/mailman/listinfo/centos
On 7/3/10, Jozsi Avadkan jozsi.avadkan@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.
post script: it's not often I actually run into something I can help with on this list. So just let me know if you need help writing that php script. Shouldn't take more than 15 minutes as long as you don't require design documentations ;)
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"; }
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@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
On 5 July 2010 15:50, John Doe jdmls@yahoo.com wrote:
From: Jozsi Avadkan jozsi.avadkan@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>
Nice and impressive.
On 07/05/2010 03:20 AM, John Doe wrote:
From: Jozsi Avadkanjozsi.avadkan@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
Both your solution and Jozsi's can produce severe security problems if <>& or " are present in the data. For example:
bash/get-ssl-certificate-from-a-domain.html debian/turn-off-all-logging.html?<!--#include file="/etc/password" --> debian/hosts/hosts.html
will do *bad things* if loaded from an Apache server with server side includes turned on.
From: Benjamin Franz jfranz@freerun.com
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>
Both your solution and Jozsi's can produce severe security problems
While this is correct, security was not a pre-requisite... but "one liner" was... ^_^ I leave it as an exercise to remove html code (sed -e ’s/<[^>]*>//g')...
JD