snipt

Ctrl+h for KB shortcuts

Text only

search in files

grep -r "<<<" .
https://snipt.net/embed/2958a767a83a6cfa75ebcb46f5f889ef/
https://snipt.net/raw/2958a767a83a6cfa75ebcb46f5f889ef/
2958a767a83a6cfa75ebcb46f5f889ef
text
Text only
1
2016-05-05T20:30:50
True
False
Apr 15, 2016 at 01:15 PM
/api/public/snipt/145429/
search-in-files-bbaed02f
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>grep -r &quot;&lt;&lt;&lt;&quot; . </span></pre></div> </td></tr></table>
commands, linux

Text only

HC

//elasticsearch version
curl -XGET 'localhost:9200' 
https://snipt.net/embed/7a0b98c3c5b21c4ad5ee69d4a2935d07/
https://snipt.net/raw/7a0b98c3c5b21c4ad5ee69d4a2935d07/
7a0b98c3c5b21c4ad5ee69d4a2935d07
text
Text only
2
2016-05-05T20:31:07
True
False
Mar 28, 2016 at 10:34 PM
/api/public/snipt/144986/
hc
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>//elasticsearch version </span><span id="L-2"><a name="L-2"></a>curl -XGET &#39;localhost:9200&#39; </span></pre></div> </td></tr></table>
linux

Bash

validate IP

[[ "$IP" =~ ^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]] && echo "valid" || echo "invalid"
https://snipt.net/embed/a9253d8df5f51a88c9becb1b4c407589/
https://snipt.net/raw/a9253d8df5f51a88c9becb1b4c407589/
a9253d8df5f51a88c9becb1b4c407589
bash
Bash
1
2016-05-05T20:32:02
True
False
Oct 18, 2015 at 12:39 PM
/api/public/snipt/141789/
validate-ip
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="o">[[</span> <span class="s2">&quot;</span><span class="nv">$IP</span><span class="s2">&quot;</span> <span class="o">=</span>~ ^<span class="o">(([</span>0-9<span class="o">]</span><span class="p">|</span><span class="o">[</span>1-9<span class="o">][</span>0-9<span class="o">]</span><span class="p">|</span>1<span class="o">[</span>0-9<span class="o">][</span>0-9<span class="o">]</span><span class="p">|</span>2<span class="o">[</span>0-4<span class="o">][</span>0-9<span class="o">]</span><span class="p">|</span>25<span class="o">[</span>0-5<span class="o">])</span>.<span class="o">){</span>3<span class="o">}([</span>0-9<span class="o">]</span><span class="p">|</span><span class="o">[</span>1-9<span class="o">][</span>0-9<span class="o">]</span><span class="p">|</span>1<span class="o">[</span>0-9<span class="o">][</span>0-9<span class="o">]</span><span class="p">|</span>2<span class="o">[</span>0-4<span class="o">][</span>0-9<span class="o">]</span><span class="p">|</span>25<span class="o">[</span>0-5<span class="o">])</span><span class="nv">$ </span><span class="o">]]</span> <span class="o">&amp;&amp;</span> <span class="nb">echo</span> <span class="s2">&quot;valid&quot;</span> <span class="o">||</span> <span class="nb">echo</span> <span class="s2">&quot;invalid&quot;</span> </span></pre></div> </td></tr></table>
bash, ip, linux

Bash

sed append to match

1
2
3
4
file="/path/to/file"
regex="find this .*"
suffix="-suffix"
sed -i "s/$regex/&$suffix/" $file
https://snipt.net/embed/940f084dd40897180b5a15ed7a27be6c/
https://snipt.net/raw/940f084dd40897180b5a15ed7a27be6c/
940f084dd40897180b5a15ed7a27be6c
bash
Bash
4
2016-05-05T20:32:40
True
False
Oct 13, 2015 at 06:33 AM
/api/public/snipt/141656/
sed-append-to-match
<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></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nv">file</span><span class="o">=</span><span class="s2">&quot;/path/to/file&quot;</span> </span><span id="L-2"><a name="L-2"></a><span class="nv">regex</span><span class="o">=</span><span class="s2">&quot;find this .*&quot;</span> </span><span id="L-3"><a name="L-3"></a><span class="nv">suffix</span><span class="o">=</span><span class="s2">&quot;-suffix&quot;</span> </span><span id="L-4"><a name="L-4"></a>sed -i <span class="s2">&quot;s/</span><span class="nv">$regex</span><span class="s2">/&amp;</span><span class="nv">$suffix</span><span class="s2">/&quot;</span> <span class="nv">$file</span> </span></pre></div> </td></tr></table>
append, bash, linux, regex, sed

Bash

Get package version from deb file

debFile="/path/to/deb/file"
dpkg -I "$debFile"  | grep -oP '(?<=Version: ).*'
https://snipt.net/embed/0bf8d894f6ead618ac4cf860825e6a34/
https://snipt.net/raw/0bf8d894f6ead618ac4cf860825e6a34/
0bf8d894f6ead618ac4cf860825e6a34
bash
Bash
2
2016-05-05T20:33:00
True
False
Oct 06, 2015 at 08:16 AM
/api/public/snipt/141521/
get-package-version-from-deb-file
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nv">debFile</span><span class="o">=</span><span class="s2">&quot;/path/to/deb/file&quot;</span> </span><span id="L-2"><a name="L-2"></a>dpkg -I <span class="s2">&quot;</span><span class="nv">$debFile</span><span class="s2">&quot;</span> <span class="p">|</span> grep -oP <span class="s1">&#39;(?&lt;=Version: ).*&#39;</span> </span></pre></div> </td></tr></table>
bash, deb, linux, package, ubuntu

Bash

get certificate validity end date

file="/path/to/cert"
openssl x509 -enddate -noout -in "$file"
https://snipt.net/embed/6b8f7fa0414e49696df5002e3239f3cb/
https://snipt.net/raw/6b8f7fa0414e49696df5002e3239f3cb/
6b8f7fa0414e49696df5002e3239f3cb
bash
Bash
2
2016-05-05T20:33:20
True
False
/api/public/snipt/141376/
get-certificate-validity-end-date
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nv">file</span><span class="o">=</span><span class="s2">&quot;/path/to/cert&quot;</span> </span><span id="L-2"><a name="L-2"></a>openssl x509 -enddate -noout -in <span class="s2">&quot;</span><span class="nv">$file</span><span class="s2">&quot;</span> </span></pre></div> </td></tr></table>
cert, expiration, linux, openssl, x509
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.