shell - Most compatible method for reading a file line-by-line in reverse -


okay, have script generates list of values (separated newlines simplicity) they're generated , stored file in 1 order, need process file in reverse order (i can't change how first step operates efficiency reasons dataset can quite large).

i'm familiar useful commands tac , tail -r in bash, unfortunately environment i'm working within has neither (i don't believe has @ in addition main posix standard).

so i'm looking best way read lines file in reverse-order, preferably little memory overhead possible, file may grow quite large (though individual lines should relatively small).

this method uses sort have high memory overhead

cat -n filename | sort -rn | cut -f2- 

if have perl installed, use module file::readbackwards.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -