资 源 简 介
bsearch distinguishes records in a file basing on a regular expression pattern. Each record is converted into an integer using the special characters enclosed in $[ ]. This integer is than used for binary search. The target string must match the pattern enclosed in $[ ].
For the gzipped text files, bsearch creates an index first to be able to randomly access the file. The index is saved into $HOME/.bsearch/index.N file. If you re-run bsearch it will read the index from the file, thus all consequent runs take just a few milliseconds. No more than 10 indexes are stored, bsearch always overrides the oldest one.
Examples:
bsearch -p "^$[YYYY/MM/DD hh:mm:ss.n+]" -k 1000000 -t "2013/04/16 09:41:25.0" log.txt.gz bsearch -p "^DEBUG | $[YYYY-MM-DD hh:mm:ss,nnn] |" -t "2008-09-06 10:51:45,458" log.txt bsearch -p "^.*? type=data id=$[n+]" -t "43567800001" log.txt.gz bsearch -t "16/04/13 09:41:25.000" -t "16/04/13 10:15:00.000" log