To get the innerHTML of the first <pre> element in an HTML document on Linux, you can use command-line tools like curl (to fetch the HTML) and xmllint or pup (to parse and extract the content).
Method 1: Using curl + pup (Recommended)
If you have pup installed (a command-line HTML parser), you can do:
bash
curl -s <URL> | pup 'pre' | head -n 1
curl -s <URL> fetches the HTML silently.
pup 'pre' extracts all <pre> elements.
head -n 1 takes the first one.
If you want the innerHTML (not just the text), use:
bash
curl -s <URL> | pup 'pre html'
Method 2: Using curl + xmllint (XPath)
If you prefer xmllint (part of libxml2), you can use XPath: