cat .bash_history | grep -E '[0-9]{1,3}\.[1-9]{1,3}\.[1-9]{1,3}\.[1-9]{1,3}'I was looking for a server I connected to a few days ago, but didn't want to search through everything manually. I'm no regex master, so I am SURE there's a better way (maybe grouping that first one and saying {3}? ...
haha yep:
[nak@arch ~]$ cat .bash_history | grep -E '([0-9]{1,3}\.){3}'
This comment has been removed by the author.
ReplyDeleteYou can catch a complete dotted quad including the last octet with a slight variation of your last grep:
ReplyDeletegrep -E '([0-9]{1,3}.){3}[0-9]{1,3}'
This way you will only catch full IPV4 addresses and not junk that could be placed in as logs such as software version numbers or dates (3.2.1 or 03.10.12).
Ah yeah, nice catch!
Delete