On 22 Mar, dizzy73 wrote:
Hi All Im trying to figgure out how to grep a file and only produce the *last* line found. I want to cat /var/log/messages | grep remote this outouts all line which contain remote, I only want the last one I plant to display onscreen my remote ip when I connect to my isp.
I looked into uniq but obiviously the datestamp makes eask entry unique
any ideas on to to use grep for my needs
thanks rob
If you need the IP address, save it off from /etc/ppp/ip-up.local, and bypass grep altogether. For example, your /etc/ppp/ip-up.local would contain the line: echo $5 > /var/run/$1.ip This would create (or overwrite) a file with your remote IP address. With dial-up, you'd get /var/run/ppp0.ip. "$5" is the remote IP address. There's a local IP address in "$4". I assume you need remote ($5). "$1" is the interface: "ppp0" for most dial-ups. Now any scripts can read the IP address from /var/run/ppp0.ip. No need for messy grep commands on your log files. For security reasons, you may want to change the permissions on /var/run/ppp0.ip. Keep unauthorized users from reading it. But I'm just being paranoid... echo $5 > /var/run/$1.ip chmod u=rw,g=r,o= /var/run/$1.ip -- Robert Wohlfarth rjwohlfar@bigfoot.com "Is not life more important than food, and the body more important than clothes?" -- Matthew 6:25b