| Newsgroups |
gmane.editors.sed.user |
| Message-ID |
<[email protected]> |
Hi,
One possible solution is as follows.
cat file1 | sed 's/ */<\/TD><TD>/g;s/.*/<TR><TD>&<\/TD><\/TR>/; s/<TR>/&\n/;s/<\/TD>/&\n/g'
output is below.
<TR><TD>google.com</TD><TD>FR</TD><TD>OK</TD><TD>2</TD><TD>September</TD><TD>2015</TD><TD>21</TD></TR><TR><TD>yahoo.com</TD><TD>FR</TD><TD>OK</TD><TD>3</TD><TD>September</TD><TD>2016</TD><TD>125</TD></TR><TR><TD>dell.com</TD><TD>US</TD><TD>OK</TD><TD>October</TD><TD>3,</TD><TD>2017</TD><TD>365</TD></TR><TR><TD>oracle.com</TD><TD>EN</TD><TD>NO</TD><TD>3</TD><TD>December</TD><TD>2015</TD><TD>542</TD></TR><TR><TD>ibm.com</TD><TD>ES</TD><TD>OK</TD><TD>November</TD><TD>18,</TD><TD>2015</TD><TD>21</TD></TR><TR><TD>sap.com</TD><TD>ES</TD><TD>NO</TD><TD>January</TD><TD>26,</TD><TD>2018</TD><TD>36</TD></TR><TR><TD>mysql.com</TD><TD>US</TD><TD>OK</TD><TD>7</TD><TD>Jul</TD><TD>2016</TD><TD>25</TD></TR>
thanksscott
On Friday, April 17, 2015 3:40 AM, "Daniel Goldman [email protected] [sed-users]" <[email protected]> wrote:
In this case, I also don't see the point of the second file. I would
rename the subject "transform input data file". :)
Here is another possible way you might do the task:
$ cat file1.txt
google.com FR OK 2 September 2015 21
yahoo.com FR OK 3 September 2016 125
dell.com US OK October 3, 2017 365
$ cat script1.sh
#!/bin/bash
while read url lang ok_no date_1 date_2 year number; do
echo "<tr>"
echo "<td> $url </td>"
echo "<td> $lang </td>"
echo "<td> $ok_no </td>"
echo "<td> $date_1 $date_2 $year </td>"
echo "<td> $number </td>"
echo "</tr>"
done
$ script1.sh < file1.txt
<tr>
<td> google.com </td>
<td> FR </td>
<td> OK </td>
<td> 2 September 2015 </td>
<td> 21 </td>
</tr>
<tr>
<td> yahoo.com </td>
<td> FR </td>
<td> OK </td>
<td> 3 September 2016 </td>
<td> 125 </td>
</tr>
<tr>
<td> dell.com </td>
<td> US </td>
<td> OK </td>
<td> October 3, 2017 </td>
<td> 365 </td>
</tr>
If the output needs to be sorted by some combination of input fields,
then do something like:
sort [some parameters] file1.txt | script1.sh
BTW, what is a "mask file"? I've never heard that term used before. Any
chance you have a reference you could share?
Daniel
On 4/16/2015 5:26 AM, MOKRANI Rachid [email protected] [sed-users]
wrote:
> I don't understand (in which way do you need the second file)
>
>
> The first file is generated by a script. The result is in text format.
>
> I need to create an html table with this result. The result need to be sort by the fifth column
>
> I thought creating an html mask file, and insert the result of my script in this file.
>
>
>
>
>
>> -----Message d'origine-----
>> De : [email protected] [mailto:[email protected]]
>> Envoyé : jeudi 16 avril 2015 14:21
>> À : [email protected]
>> Objet : Re: two files in one file
>>
>> in which way do you need the second file? If you just want to make the
>> file into a html table, it is easy.
>>
>>
>>
>> On 16/04/15 11:14, MOKRANI Rachid [email protected] [sed-users]
>> wrote:
>>> Hi,
>>>
>>> Using data from a text file I want to create an HTML table.
>>>
>>> I have a first file with data like : (this file is generate automatically, and the
>> line order can change )
>>> google.com FR OK 2 September 2015 21
>>> yahoo.com FR OK 3 September 2016 125
>>> dell.com US OK October 3, 2017 365
>>> oracle.com EN NO 3 December 2015 542
>>> ibm.com ES OK November 18, 2015 21
>>> sap.com ES NO January 26, 2018 36
>>> mysql.com US OK 7 Jul 2016 25
>>> etc ....
>>>
>>>
>>> My second file (second.html) is a mask in html format.
>>>
>>> ....
>>> ....
>>> <TR>
>>> <TD> Value B1 </ TD>
>>> <TD> Value B2 </ TD>
>>> <TD> Value B3 </ TD>
>>> <TD> Value B4 </ TD>
>>> <TD> Value B5 </ TD>
>>> </ TR>
>>> <TR>
>>> <TD> Value C1 </ TD>
>>> <TD> Value C2</ TD>
>>> <TD> Value C3</ TD>
>>> <TD> Value C4 </ TD>
>>> <TD> Value C5 </ TD>
>>> </ TR>
>>>
>>> <TR>
>>> <TD> Value D1 </ TD>
>>> <TD> Value D2 </ TD>
>>> <TD> Value D3 </ TD>
>>> <TD> Value D4 </ TD>
>>> <TD> Value D5 </ TD>
>>> </ TR>
>>> ...
>>> ....
>>> I need to obtain a third file like this. Data from my first file need to insert in
>> my second file for the following result.
>>>
>>> ....
>>> ....
>>> <TR>
>>> <TD> google.com </ TD>
>>> <TD> FR </ TD>
>>> <TD> OK </ TD>
>>> <TD> 2 September 2015</ TD>
>>> <TD> 21 </ TD>
>>> </ TR>
>>> <TR>
>>> <TD> yahoo.com </ TD>
>>> <TD> FR </ TD>
>>> <TD> OK </ TD>
>>> <TD> 3 September 2016</ TD>
>>> <TD> 125 </ TD>
>>> </ TR>
>>>
>>> <TR>
>>> <TD> dell.com </ TD>
>>> <TD> US </ TD>
>>> <TD> OK </ TD>
>>> <TD> October 3, 2017</ TD>
>>> <TD> 365 </ TD>
>>> </ TR>
>>> ...
>>> ....etc...
>>>
>>>
>>>
>>>
>>> Any help ?
>>>
>>> Best regards.
>>>
>>>
>>>
>>>
>>>
>>> __________________________
>>> Avant d'imprimer, pensez à l'environnement ! Please consider the
>> environment before printing !
>>> Ce message et toutes ses pièces jointes sont confidentiels et établis à
>> l'intention exclusive de ses destinataires. Toute utilisation non conforme à sa
>> destination, toute diffusion ou toute publication, totale ou partielle, est
>> interdite, sauf autorisation expresse. IFP Energies nouvelles décline toute
>> responsabilité au titre de ce message. This message and any attachments are
>> confidential and intended solely for the addressees. Any unauthorised use or
>> dissemination is prohibited. IFP Energies nouvelles should not be liable for
>> this message.
>>> __________________________
>>>
>>>
>>> [Non-text portions of this message have been removed]
>>>
>>>
>>>
>>> ------------------------------------
>>> Posted by: MOKRANI Rachid <[email protected]>
>>> ------------------------------------
>>>
>>
>>
>>
>> ------------------------------------
>> Posted by: Thierry Blanc <[email protected]>
>> ------------------------------------
>>
>> --
>>
>> ------------------------------------
>>
>> Yahoo Groups Links
>>
>>
>>
> __________________________
> Avant d'imprimer, pensez à l'environnement ! Please consider the environment before printing !
> Ce message et toutes ses pièces jointes sont confidentiels et établis à l'intention exclusive de ses destinataires. Toute utilisation non conforme à sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse. IFP Energies nouvelles décline toute responsabilité au titre de ce message. This message and any attachments are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited. IFP Energies nouvelles should not be liable for this message.
> __________________________
>
>
> ------------------------------------
> Posted by: MOKRANI Rachid <[email protected]>
> ------------------------------------
>
#yiv1617279563 #yiv1617279563 -- #yiv1617279563ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv1617279563 #yiv1617279563ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv1617279563 #yiv1617279563ygrp-mkp #yiv1617279563hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv1617279563 #yiv1617279563ygrp-mkp #yiv1617279563ads {margin-bottom:10px;}#yiv1617279563 #yiv1617279563ygrp-mkp .yiv1617279563ad {padding:0 0;}#yiv1617279563 #yiv1617279563ygrp-mkp .yiv1617279563ad p {margin:0;}#yiv1617279563 #yiv1617279563ygrp-mkp .yiv1617279563ad a {color:#0000ff;text-decoration:none;}#yiv1617279563 #yiv1617279563ygrp-sponsor #yiv1617279563ygrp-lc {font-family:Arial;}#yiv1617279563 #yiv1617279563ygrp-sponsor #yiv1617279563ygrp-lc #yiv1617279563hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv1617279563 #yiv1617279563ygrp-sponsor #yiv1617279563ygrp-lc .yiv1617279563ad {margin-bottom:10px;padding:0 0;}#yiv1617279563 #yiv1617279563actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv1617279563 #yiv1617279563activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv1617279563 #yiv1617279563activity span {font-weight:700;}#yiv1617279563 #yiv1617279563activity span:first-child {text-transform:uppercase;}#yiv1617279563 #yiv1617279563activity span a {color:#5085b6;text-decoration:none;}#yiv1617279563 #yiv1617279563activity span span {color:#ff7900;}#yiv1617279563 #yiv1617279563activity span .yiv1617279563underline {text-decoration:underline;}#yiv1617279563 .yiv1617279563attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv1617279563 .yiv1617279563attach div a {text-decoration:none;}#yiv1617279563 .yiv1617279563attach img {border:none;padding-right:5px;}#yiv1617279563 .yiv1617279563attach label {display:block;margin-bottom:5px;}#yiv1617279563 .yiv1617279563attach label a {text-decoration:none;}#yiv1617279563 blockquote {margin:0 0 0 4px;}#yiv1617279563 .yiv1617279563bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv1617279563 .yiv1617279563bold a {text-decoration:none;}#yiv1617279563 dd.yiv1617279563last p a {font-family:Verdana;font-weight:700;}#yiv1617279563 dd.yiv1617279563last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv1617279563 dd.yiv1617279563last p span.yiv1617279563yshortcuts {margin-right:0;}#yiv1617279563 div.yiv1617279563attach-table div div a {text-decoration:none;}#yiv1617279563 div.yiv1617279563attach-table {width:400px;}#yiv1617279563 div.yiv1617279563file-title a, #yiv1617279563 div.yiv1617279563file-title a:active, #yiv1617279563 div.yiv1617279563file-title a:hover, #yiv1617279563 div.yiv1617279563file-title a:visited {text-decoration:none;}#yiv1617279563 div.yiv1617279563photo-title a, #yiv1617279563 div.yiv1617279563photo-title a:active, #yiv1617279563 div.yiv1617279563photo-title a:hover, #yiv1617279563 div.yiv1617279563photo-title a:visited {text-decoration:none;}#yiv1617279563 div#yiv1617279563ygrp-mlmsg #yiv1617279563ygrp-msg p a span.yiv1617279563yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv1617279563 .yiv1617279563green {color:#628c2a;}#yiv1617279563 .yiv1617279563MsoNormal {margin:0 0 0 0;}#yiv1617279563 o {font-size:0;}#yiv1617279563 #yiv1617279563photos div {float:left;width:72px;}#yiv1617279563 #yiv1617279563photos div div {border:1px solid #666666;height:62px;overflow:hidden;width:62px;}#yiv1617279563 #yiv1617279563photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv1617279563 #yiv1617279563reco-category {font-size:77%;}#yiv1617279563 #yiv1617279563reco-desc {font-size:77%;}#yiv1617279563 .yiv1617279563replbq {margin:4px;}#yiv1617279563 #yiv1617279563ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv1617279563 #yiv1617279563ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv1617279563 #yiv1617279563ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv1617279563 #yiv1617279563ygrp-mlmsg select, #yiv1617279563 input, #yiv1617279563 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv1617279563 #yiv1617279563ygrp-mlmsg pre, #yiv1617279563 code {font:115% monospace;}#yiv1617279563 #yiv1617279563ygrp-mlmsg * {line-height:1.22em;}#yiv1617279563 #yiv1617279563ygrp-mlmsg #yiv1617279563logo {padding-bottom:10px;}#yiv1617279563 #yiv1617279563ygrp-msg p a {font-family:Verdana;}#yiv1617279563 #yiv1617279563ygrp-msg p#yiv1617279563attach-count span {color:#1E66AE;font-weight:700;}#yiv1617279563 #yiv1617279563ygrp-reco #yiv1617279563reco-head {color:#ff7900;font-weight:700;}#yiv1617279563 #yiv1617279563ygrp-reco {margin-bottom:20px;padding:0px;}#yiv1617279563 #yiv1617279563ygrp-sponsor #yiv1617279563ov li a {font-size:130%;text-decoration:none;}#yiv1617279563 #yiv1617279563ygrp-sponsor #yiv1617279563ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv1617279563 #yiv1617279563ygrp-sponsor #yiv1617279563ov ul {margin:0;padding:0 0 0 8px;}#yiv1617279563 #yiv1617279563ygrp-text {font-family:Georgia;}#yiv1617279563 #yiv1617279563ygrp-text p {margin:0 0 1em 0;}#yiv1617279563 #yiv1617279563ygrp-text tt {font-size:120%;}#yiv1617279563 #yiv1617279563ygrp-vital ul li:last-child {border-right:none !important;}#yiv1617279563
[Non-text portions of this message have been removed]