I want to display the last 10 lines of my log file, starting with the last line- like a normal log reader. I thought this would be a variation of the tail command,
You can do that with pure bash:
#!/bin/bash readarray file lines=$(( ${#file[@]} - 1 )) for (( line=$lines, i=${1:-$lines}; (( line >= 0 && i > 0 )); line--, i-- )); do echo -ne "${file[$line]}" done
./tailtac 10 < somefile ./tailtac -10 < somefile ./tailtac 100000 < somefile ./tailtac < somefile
./tailtac 10 < somefile
./tailtac -10 < somefile
./tailtac 100000 < somefile
./tailtac < somefile