table html shellscript

Asked

Viewed 242 times

1

Guys, anyone who knows shellscript know how to create this requested script in the image below? I’m doing some exercises with the theme, and that kind of got me.

Sheelscript

3 answers

3


Try it this way :

#!/bin/bash

# make_page -Sua Página

cat <<- _EOF_
<html>
    <head>
        <title>
            Minha Lista
        </title>
    </head>
<body>
    <span>Itens:</span>"
    <ul>
        <li>item 1</li>
        <li>item 2</li> 
        <li>item 3</li>
        <li>item 4</li>
        <li>item 5</li>
    </ul>
</body>
</html>
_EOF_
  • So it would not even be necessary to use grep and awk?

  • @Maylacampos, does not respond to the statement but is cool! + 1 . Maybe replace the items by $A and calculate A based on the parameters: for a in "$@"; do A=$A"<li>$a</li>"; done

2

Assuming the html code is in file.html,

grep -Po '<li>\K.*(?=</li>)' file.html

1

An option with sed:

sed -n '/item/p' file.html | sed -e 's/<[^>]*>//g'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.