Using bash to export an comma separated list to html
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
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 dont 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 =)
bash shell html css
add a comment |Â
up vote
2
down vote
favorite
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 dont 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 =)
bash shell html css
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
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 dont 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 =)
bash shell html css
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 dont 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 =)
bash shell html css
bash shell html css
asked 1 hour ago
Aryat Mapreh
134
134
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
Your quoting is wrong, specifically the double double-quotes.
Let's break down what you have, the bits concatenated together
echo ""<tr onmouseover="this.style.backgroundColor='#ffff66';"";
- the echo command
- an empty string
""
- a redirection
<tr
-- this is where the "file not found" error comes from - a space
- a string
onmouseover="this.style.backgroundColor='#ffff66';"
- an open quote and semicolon, the first character of the next string
To fix your echo commands:
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
When you have a blend of single and double quotes, a heredoc is very readable. Also, use the read
command to separate your CSV line.
while IFS=, read -r first second ; do
echo <<END_HTML
<tr onmouseover="this.style.backgroundColor='#ffff66'" onmouseout="this.style.backgroundColor='#d4e3e5'">
<td>$first</td><td><b>$second</b></td>
</tr>
END_HTML
done
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
Your quoting is wrong, specifically the double double-quotes.
Let's break down what you have, the bits concatenated together
echo ""<tr onmouseover="this.style.backgroundColor='#ffff66';"";
- the echo command
- an empty string
""
- a redirection
<tr
-- this is where the "file not found" error comes from - a space
- a string
onmouseover="this.style.backgroundColor='#ffff66';"
- an open quote and semicolon, the first character of the next string
To fix your echo commands:
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
When you have a blend of single and double quotes, a heredoc is very readable. Also, use the read
command to separate your CSV line.
while IFS=, read -r first second ; do
echo <<END_HTML
<tr onmouseover="this.style.backgroundColor='#ffff66'" onmouseout="this.style.backgroundColor='#d4e3e5'">
<td>$first</td><td><b>$second</b></td>
</tr>
END_HTML
done
add a comment |Â
up vote
3
down vote
Your quoting is wrong, specifically the double double-quotes.
Let's break down what you have, the bits concatenated together
echo ""<tr onmouseover="this.style.backgroundColor='#ffff66';"";
- the echo command
- an empty string
""
- a redirection
<tr
-- this is where the "file not found" error comes from - a space
- a string
onmouseover="this.style.backgroundColor='#ffff66';"
- an open quote and semicolon, the first character of the next string
To fix your echo commands:
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
When you have a blend of single and double quotes, a heredoc is very readable. Also, use the read
command to separate your CSV line.
while IFS=, read -r first second ; do
echo <<END_HTML
<tr onmouseover="this.style.backgroundColor='#ffff66'" onmouseout="this.style.backgroundColor='#d4e3e5'">
<td>$first</td><td><b>$second</b></td>
</tr>
END_HTML
done
add a comment |Â
up vote
3
down vote
up vote
3
down vote
Your quoting is wrong, specifically the double double-quotes.
Let's break down what you have, the bits concatenated together
echo ""<tr onmouseover="this.style.backgroundColor='#ffff66';"";
- the echo command
- an empty string
""
- a redirection
<tr
-- this is where the "file not found" error comes from - a space
- a string
onmouseover="this.style.backgroundColor='#ffff66';"
- an open quote and semicolon, the first character of the next string
To fix your echo commands:
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
When you have a blend of single and double quotes, a heredoc is very readable. Also, use the read
command to separate your CSV line.
while IFS=, read -r first second ; do
echo <<END_HTML
<tr onmouseover="this.style.backgroundColor='#ffff66'" onmouseout="this.style.backgroundColor='#d4e3e5'">
<td>$first</td><td><b>$second</b></td>
</tr>
END_HTML
done
Your quoting is wrong, specifically the double double-quotes.
Let's break down what you have, the bits concatenated together
echo ""<tr onmouseover="this.style.backgroundColor='#ffff66';"";
- the echo command
- an empty string
""
- a redirection
<tr
-- this is where the "file not found" error comes from - a space
- a string
onmouseover="this.style.backgroundColor='#ffff66';"
- an open quote and semicolon, the first character of the next string
To fix your echo commands:
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
When you have a blend of single and double quotes, a heredoc is very readable. Also, use the read
command to separate your CSV line.
while IFS=, read -r first second ; do
echo <<END_HTML
<tr onmouseover="this.style.backgroundColor='#ffff66'" onmouseout="this.style.backgroundColor='#d4e3e5'">
<td>$first</td><td><b>$second</b></td>
</tr>
END_HTML
done
answered 26 mins ago
glenn jackman
15.3k12643
15.3k12643
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1368590%2fusing-bash-to-export-an-comma-separated-list-to-html%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password