snipt

Ctrl+h for KB shortcuts

Bash

Find IPs in file

1
2
3
4
5
#!/bin/sh
grep -Eo "[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}" /usr/local/psa/var/log/maillog |
    while read i;do
    echo $i
done
https://snipt.net/embed/2587db67e85935effe7f60b8ae72dc76/
/raw/2587db67e85935effe7f60b8ae72dc76/
2587db67e85935effe7f60b8ae72dc76
bash
Bash
5
2019-07-22T22:32:25
True
False
False
/api/public/snipt/49357/
find-ips-in-file
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="ch">#!/bin/sh</span> </span><span id="L-2"><a name="L-2"></a>grep -Eo <span class="s2">&quot;[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}&quot;</span> /usr/local/psa/var/log/maillog <span class="p">|</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">while</span> <span class="nb">read</span> i<span class="p">;</span><span class="k">do</span> </span><span id="L-4"><a name="L-4"></a> <span class="nb">echo</span> <span class="nv">$i</span> </span><span id="L-5"><a name="L-5"></a><span class="k">done</span> </span></pre></div> </td></tr></table>