How can I loop through the file starting at the end and going backward one line at a time? Can -tail be used for this? I do not want to read only the last 5 lines because I want to use a more complicated condition than the one above. Instead, I want to read the file backwards, starting at the last line then moving up one line at a time.
#!/bin/bash while read LINE do if [ $(( i )) -lt 5 ]; then i=$((i+1)) echo $LINE else break fi done <"$1"