#!/usr/bin/env bash # count lines in resolv.conf lines=$(cat /run/libreelec/resolv.conf | wc -l) # count number of 'nameserver' entries count=$(grep -c 'nameserver' /run/libreelec/resolv.conf) # move last entry to top i=$((0)) while [ $((count)) -gt 1 ]; do sed -i -n "$((lines - i - 1)){h;n;G};p" /run/libreelec/resolv.conf count=$((count - 1)) i=$((i + 1)) done exit 0