I am working with a very large file and I need to access the last few entries at the bottom, so using tail would be good, but the problem is the number of lines read changes each time. However, I know I need to stop when a new line character is found so I was wondering if there is a way to do this?
Any help is appreciated. Thanks.
tac
is your friend it is cat
in reverse
tac yourfile|while read LINE; do if [[ -z "$LINE" ]] ; then break; fi; echo $LINE; done
This read the file reverse and stop on first empty line
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.