snipt

Ctrl+h for KB shortcuts

Bash

Recursively find and list the last modified files in a directory

stat --printf="%y %n\n" $(ls -tr $(find * -type f))
https://snipt.net/embed/658e81891f567c2b90931e8f90e60846/
/raw/658e81891f567c2b90931e8f90e60846/
658e81891f567c2b90931e8f90e60846
bash
Bash
1
2019-08-19T10:23:23
True
False
False
Jan 31, 2014 at 06:10 AM
/api/public/snipt/109821/
recursively-find-and-list-the-last-modified-files-in-a-directory
<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>stat --printf<span class="o">=</span><span class="s2">&quot;%y %n\n&quot;</span> <span class="k">$(</span>ls -tr <span class="k">$(</span>find * -type f<span class="k">))</span> </span></pre></div> </td></tr></table>
date, find, ls, stat

Bash

Measure use of memory from a program

$> valgrind -v <program> <arguments>
https://snipt.net/embed/5b9d771ed706564408b15a84f88606b9/
/raw/5b9d771ed706564408b15a84f88606b9/
5b9d771ed706564408b15a84f88606b9
bash
Bash
1
2019-08-19T18:57:21
True
False
False
/api/public/snipt/6370/
measure-use-of-memory-from-a-program
<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>$&gt; valgrind -v &lt;program&gt; &lt;arguments&gt; </span></pre></div> </td></tr></table>
kernel, linux, stat

Bash

Measure performance, time and calls from a program

1
2
3
$> callgrind -v <program> <arguments>
# this generate a file <program>.out.<pid>
$> kcachegrind <program>.out.<pid>
https://snipt.net/embed/0ea9d967d7b8f4137661f27d6586c9d4/
/raw/0ea9d967d7b8f4137661f27d6586c9d4/
0ea9d967d7b8f4137661f27d6586c9d4
bash
Bash
4
2019-08-19T16:35:20
True
False
False
/api/public/snipt/6369/
measure-performance-time-and-calls-from-a-program
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$&gt; callgrind -v &lt;program&gt; &lt;arguments&gt; </span><span id="L-2"><a name="L-2"></a><span class="c1"># this generate a file &lt;program&gt;.out.&lt;pid&gt;</span> </span><span id="L-3"><a name="L-3"></a>$&gt; kcachegrind &lt;program&gt;.out.&lt;pid&gt; </span></pre></div> </td></tr></table>
kernel, linux, stat

Bash

Display file permissions in octal format

stat -c '%A %a %n' *
https://snipt.net/embed/5f7fb271b265c772c48239d7fe1453da/
/raw/5f7fb271b265c772c48239d7fe1453da/
5f7fb271b265c772c48239d7fe1453da
bash
Bash
1
2019-08-23T13:17:39
True
False
False
/api/public/snipt/5209/
display-file-permissions-in-octal-format
<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>stat -c <span class="s1">&#39;%A %a %n&#39;</span> * </span></pre></div> </td></tr></table>
bash, octal, stat

Bash

memory footprint of own processes

ps -x -o pid,rss,command | awk '{print $0}{sum+=$2} END {print "Total", sum}'
https://snipt.net/embed/71c793a27bb199a4b7fd2b09179324da/
/raw/71c793a27bb199a4b7fd2b09179324da/
71c793a27bb199a4b7fd2b09179324da
bash
Bash
1
2019-08-22T05:02:12
True
False
False
/api/public/snipt/2016/
memory-footprint-of-own-processes
<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 -x -o pid,rss,command <span class="p">|</span> awk <span class="s1">&#39;{print $0}{sum+=$2} END {print &quot;Total&quot;, sum}&#39;</span> </span></pre></div> </td></tr></table>
memory, shell, stat