2
I've got a cxomma-separated csv that I want to turn into custom html, and I ran into another script which did it, but it's been nothing but issues for me since I use https://www.tutorialspoint.com/execute_bash_online.php to run it.
Here's the script I found: https://unix.stackexchange.com/questions/105501/convert-csv-to-html-table
My problem is that my output needs to be a bit different, and something about ECHO is really putting up a fight. So here's an example of my list:
Product,100 usd Now using this script I want to convert that to look like: Product100 usd
Basically separating the list into 2 cells. But echo keeps stripping out "'s so it's just a mess. I don't know if it's because the bash emulator wraps lines, but I keep getting errors, where it seems to assume >< and tr as well as td is a command.
Currently my script looks like this, and it reflects how much i've stuggled with echo..:
while read INPUT ; do
echo ""<tr onmouseover="this.style.backgroundColor='#ffff66';"";
echo ""onmouseout="this.style.backgroundColor='#d4e3e5';>";
echo ""<td>${INPUT//,/</td><td><b>}</b></td></tr>";""
done
And that generates:
$bash -f main.sh
main.sh: line 2: tr: No such file or directory
main.sh: line 4: ;
echo <td>six</td><td><b>nine</td><td><b>twelve</b></td></tr>: No such file or directory
main.sh: line 4: : command not found
I've experimented like crazy with echo, but now I'm at my wit's end. Any and all help greatly and gratefully accepted.
2
echo
doesn't read from stdin, so a heredoc would not be useful here. Perhaps you meant to usecat
in that last snippet instead? – jwodder – 2018-10-21T03:12:14.960