I have the following file below with the format and I want to pass the value to HTML

BE64533-A0E1-4F98-A91F-02C1D0 column=ABC_Received:ABC_Structure_Type, timestamp=1439978656596, **value=ASCII**
BE64533-A0E1-4F8-A9F-03CE2C1D0 column=ABC_Received:Current_To, timestamp=1439978656596, **value=RPI** 

How do I get the value (ASCII and RPI) from this file and pass to STATIC HTML Tags. I have HTML tag below as where I want to enclose this value (ASCII and RPI)

<!--Row 1 Header -->
<td class="HeaderCell">ABC_Structure_Type</td>
<td class="HeaderCell">Current_To</td>

<!--Row 1 Values -->
<td  class="ValueCell">[ABC_Structure_Type]</td>
<td  class="ValueCell">[_Current_To]</td>

Output needed is as shown below

<!--Row 1 Values -->
<td  class="ValueCell">ASCII</td>
<td  class="ValueCell">RPI</td>

From the file , They need to be replaced in the row 1 values [ABC_Structure_Type] and [Current_To] from the file that has value as ASCII and RPI respectively

closed as unclear what you're asking by Anthon, chaos, X Tian, jimmij, taliezin Aug 19 '15 at 15:38

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • What do you mean by "pass to static html tags"? Do you want to put html tags around those values? Please give an example, and the desired output. – chaos Aug 19 '15 at 12:59
  • 1
    I'm sorry but it's still unclear; please show the exact output you want. Should ASCII and RPI replace ValueCell or should they replace [ABC_Structure_Type] and [_Current_To]? – chaos Aug 19 '15 at 13:17

Well, it's not that clear, what you actually want to do, but it's clear, that you need to parse those values out of the file of yours. To do this, just put the values in separate arrays, like this (you need to set YourFile with the actual file with the values):

while read -r Line; do 
  H+=("$( printf "%s" "$Line" | grep -o 'column=[^,]*' | sed 's/^column=ABC_Received://')" )
  V+=("$( printf "%s" "$Line" | grep -o ' \*\*value=.*\*\*$' | sed 's/.*=\(.*\)\*\*$/\1/' )")
done < "$YourFile"

To check, that you got the arrays filled correctly, just run

printf "%s\n" "${H[@]}"
printf "%s\n" "${V[@]}"

If you just want to create a stub for a static HTML-page, you can do it now easily, if you edit the printfs above or with an easy loop (if you want to do something different with the values):

for v in "${H[@]}"; do 
  printf '<td class="HeaderCell">%s</td>\n' "$v"

for v in "${V[@]}"; do 
  printf '<td class="ValueCell">%s</td>\n' "$v"

Output with your example values would be:

<td class=HeaderCell>ABC_Structure_Type</td>
<td class=HeaderCell>Current_To</td>
<td class=ValueCell>ASCII</td>
<td class=ValueCell>RPI</td>

Of course, you can now do whatever you want with those values (not just printfs).

Disclaimer: GNU/bash script…


Well, assuming that a) the first two parts of the id-field are the key to group two lines together, and b) you may also use perl from the commandline, the following script will parse out the values - fields, and convert it to a html output from a given input-file:

my $fn=shift;
my ($ABC_found,$ASCII,$RPI,$ID)=(0,"","","");
open(FIN,"<",$fn) || die ("cannot open infile $fn");
sub print_html {
    $asc = shift;
    $rpi = shift;
<!--Row 1 Header -->
<td class='HeaderCell'>ABC_Structure_Type</td>
<td class='HeaderCell'>Current_To</td>
<!--Row 1 Values -->
<td  class='ValueCell'>$asc</td>
<td  class='ValueCell'>$rpi</td>

while (<FIN>) {
    if ($ABC_found==0 && m/^([\w\d]*)[\-]([\w\d]*).*ABC_Structure.*,        [\s]timestamp=.*,[\s]value=(.*)$/) {
        # print("ASCII : [$1]-[$2] : [$3]\n");
    } elsif ($ABC_found==1 && m/^$ID.*Current_To.*[\s]timestamp=.*,[\s]value=(.*)$/) {
        # print("RPI : [$1]\n");
    } else {    


$> perl script.pl inputfile.txt

Have fun !

Not the answer you're looking for? Browse other questions tagged or ask your own question.