bash - is it possible to scan a file in reverse (bottom up) using ack? -
is possible scan file pattern in reverse (bottom up) using ack (the grep alternative)?
right using:
tac filename | grep -m1 blablabla
but friend mentioned ack might able type of thing without use of tac. went through man file , not find mentioning capability (or maybe dumb , missed it).
if not possible above, more efficient way of doing type of search? (find first match of pattern starting @ bottom of file)
reading file in such reverse line-oriented fashion going inefficient, due how files stored on disk. file linear stream of bytes, accessible offset beginning file. line not distinct object; rather, it's abstraction defined conventional byte (or pair of bytes) know line ending. first line beginning of file first line ending, second line after first line ending second line ending, , on. in order access lines in reverse, still need scan entire file beginning find last line.
the command line have can do. i'm not aware of option ack
reverse line-iteration you, if did, marginally more efficient letting dedicated program tac
handle (the difference coming doing file i/o itself, rather having overhead of second process , setting interprocess communication of pipe).