Files
ethtool/check-version.sh
T
2025-05-10 15:48:53 +03:00

25 lines
720 B
Bash

#!/bin/bash
# Webpage URL
URL="https://www.kernel.org/pub/software/network/ethtool/"
# Cell to extract
ROW=2
COLUMN=1
# Get HTML table from webpage
HTML_TABLE=$(curl -s -L "$URL" | sed -n -e '/<table>/,/<\/table>/ p' | sed -e 's/^[ \t]*//')
# Get row from $HTML_TABLE
ROW_START=$(echo "$HTML_TABLE" | grep -n -m$ROW '<tr>' | tail -n1 | cut -d':' -f1)
ROW_END=$(echo "$HTML_TABLE" | grep -n -m$ROW '</tr>' | tail -n1 | cut -d':' -f1)
HTML_ROW=$(echo "$HTML_TABLE" | sed "$ROW_START,$ROW_END !d")
# Get column from $HTML_ROW
HTML_COLUMN=$(echo "$HTML_ROW" | grep -m$COLUMN '^<td>' | tail -n1)
# Get version by removing HTML tags from $HTML_COLUMN
VERSION=$(echo "$HTML_COLUMN" | sed 's|<[^>]*>||g')
echo "$VERSION"