#!/bin/sh

# This script reads a list of kernel module file names, one per line, and outputs the respective kernel versions
# according to the default naming scheme (i.e., `.../collector-$(uname -r).ko`, with an optional `.gz` suffix).

sed -e 's@^\(.*/\)\{0,1\}collector-\([^/]\{1,\}\)\.ko\(\.gz\)\{0,1\}$@!!! \2 mod@g' \
    | sed -e 's@^\(.*/\)\{0,1\}collector-ebpf-\([^/]\{1,\}\)\.o\(\.gz\)\{0,1\}$@!!! \2 bpf@g' \
    | sed -e 's@^\(.*/\)\{0,1\}\.collector-ebpf-\([^/]\{1,\}\)\.unavail$@!!! \2 bpf@g' \
    | sed -ne 's@^!!! \(.*\)$@\1@p'
