I want to get delete all of the blank lines and lines with spaces (if any exist (ONLY from the bottom of the file)) and then to remove one more line (also ONLY from the bottom of the file).
I have this code:
while [[ "$last_line" =~ ^$ ]] || [[ "$last_line" =~ ^[[:space:]]+$ ]]
do
sed -i -e '${/$/d}' "./file.txt"
done
sed -i -e '${/$/d}' "./file.txt"
For some reason the loop doesn't stop and it deletes everything in the file. What is the matter?
$last_linewithin the loop, so how could it stop?