views:

65

answers:

3

hi, what is the option with grep or egrep through which we can search from bottom to up of a file normally they works in the top to bottom

+2  A: 
tac your.log | grep stuff
mosg
Shame on Mac OS X not including that program!
Arafangion
Ups, and linux has it!
mosg
You can get it throug macports (coreutils), it will be named gtac.
DiggyF
A: 

If you can stand the delay, I'd consider just piping the result through the rev program.

Arafangion
it will greatful if you will show this solution by example
sunil
Something along the lines of...: grep whatever | rev -
Arafangion
A: 
#!/bin/bash

start=10
while true
do
  if tail -${start} "file" | grep -q "search" ;then
    tail -${start} "file" | grep "search"
    exit
  else
    ((start+=10))
  fi
done
ghostdog74
That looks like a VERY slow solution, and only reverses by chunks.
Arafangion