echo "CTID,HOSTNAME,HOST_PATH,CONTAINER_PATH" > lxc-mounts.csv

for conf in /etc/pve/lxc/*.conf; do
  CTID=$(basename "$conf" .conf)
  HOSTNAME=$(grep -E '^hostname:' "$conf" | awk '{print $2}')

  grep -E '^mp[0-9]+:' "$conf" | while read -r line; do
    HOSTPATH=$(echo "$line" | cut -d':' -f2 | cut -d',' -f1 | xargs)
    CONTPATH=$(echo "$line" | sed -n 's/.*mp=\([^,]*\).*/\1/p')
    echo "$CTID,$HOSTNAME,$HOSTPATH,$CONTPATH" >> lxc-mounts.csv
  done
done
