snipt

Ctrl+h for KB shortcuts

Bash

buscar archivos por permiso

#buscará los archivos con permiso s en grupo
find . -perm -g=s 
https://snipt.net/embed/7fb2c1de149218ad21cad873b6e085d7/
/raw/7fb2c1de149218ad21cad873b6e085d7/
7fb2c1de149218ad21cad873b6e085d7
bash
Bash
2
2019-07-21T11:05:42
True
False
False
/api/public/snipt/28614/
buscar-archivos-por-permiso
<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></span><span id="L-1"><a name="L-1"></a><span class="c1">#buscará los archivos con permiso s en grupo</span> </span><span id="L-2"><a name="L-2"></a>find . -perm -g<span class="o">=</span>s </span></pre></div> </td></tr></table>
bash, chmod, find, permission

Bash

Promedios de memoria, ejemplo con apache

ps aux|grep apache2|grep -v 'grep'|awk '{s+=$6} END {print "N.Proc",NR," | MemTotal=",s/1024,"M | MemAvg=",(s/NR)/1024,"M"}'
https://snipt.net/embed/1653e3f68ad5ff39a361ea20e3d70e80/
/raw/1653e3f68ad5ff39a361ea20e3d70e80/
1653e3f68ad5ff39a361ea20e3d70e80
bash
Bash
2
2019-07-21T10:46:40
True
False
False
/api/public/snipt/24860/
promedios-de-memoria
<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></span><span id="L-1"><a name="L-1"></a>ps aux<span class="p">|</span>grep apache2<span class="p">|</span>grep -v <span class="s1">&#39;grep&#39;</span><span class="p">|</span>awk <span class="s1">&#39;{s+=$6} END {print &quot;N.Proc&quot;,NR,&quot; | MemTotal=&quot;,s/1024,&quot;M | MemAvg=&quot;,(s/NR)/1024,&quot;M&quot;}&#39;</span> </span></pre></div> </td></tr></table>
apache, bash, procesos, server

Bash

Renombrar de [1-9].jpg a [01-09].jpg

for a in [1-9].jpg;do mv $a `printf %02d.%s ${a%.*} ${a##*.}`; done
https://snipt.net/embed/8812d182bee590adb4f43b998e6a54bd/
/raw/8812d182bee590adb4f43b998e6a54bd/
8812d182bee590adb4f43b998e6a54bd
bash
Bash
1
2019-07-22T11:45:54
True
False
False
/api/public/snipt/20406/
renombrar-de-1-9jpg-a-01-09jpg
<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></span><span id="L-1"><a name="L-1"></a><span class="k">for</span> a in <span class="o">[</span>1-9<span class="o">]</span>.jpg<span class="p">;</span><span class="k">do</span> mv <span class="nv">$a</span> <span class="sb">`</span><span class="nb">printf</span> %02d.%s <span class="si">${</span><span class="nv">a</span><span class="p">%.*</span><span class="si">}</span> <span class="si">${</span><span class="nv">a</span><span class="p">##*.</span><span class="si">}</span><span class="sb">`</span><span class="p">;</span> <span class="k">done</span> </span></pre></div> </td></tr></table>
bash, linux, rename

Bash

number of file open by command

lsof | awk '{printf("%s\n",$1)}' | sort | uniq -c | sort -n
https://snipt.net/embed/75ca64e0793a44cbe1d4ec8120e4a6d7/
/raw/75ca64e0793a44cbe1d4ec8120e4a6d7/
75ca64e0793a44cbe1d4ec8120e4a6d7
bash
Bash
2
2019-07-17T17:54:27
True
False
False
/api/public/snipt/12772/
number-of-file-open-by-command
<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></span><span id="L-1"><a name="L-1"></a>lsof <span class="p">|</span> awk <span class="s1">&#39;{printf(&quot;%s\n&quot;,$1)}&#39;</span> <span class="p">|</span> sort <span class="p">|</span> uniq -c <span class="p">|</span> sort -n </span></pre></div> </td></tr></table>
awk, bash, files, lsof, sh, sort, uniq