snipt

Ctrl+h for KB shortcuts

Bash

Uninstall old XCode before installing new version

sudo /Developer/Library/uninstall-devtools --mode=all
https://snipt.net/embed/33a4b64ca886605e85e8921d831f05c3/
/raw/33a4b64ca886605e85e8921d831f05c3/
33a4b64ca886605e85e8921d831f05c3
bash
Bash
1
2019-07-21T02:39:13
True
False
False
/api/public/snipt/1137/
uninstall-old-xcode-before-installing-new-version
<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>sudo /Developer/Library/uninstall-devtools --mode<span class="o">=</span>all </span></pre></div> </td></tr></table>
bash, mac, xcode

Bash

tar and zip an entire folder

tar cvzfp site.tgz /home/user/public_html
https://snipt.net/embed/57a47c629711876cecbeb8267cb8a528/
/raw/57a47c629711876cecbeb8267cb8a528/
57a47c629711876cecbeb8267cb8a528
bash
Bash
1
2019-07-16T06:10:30
True
False
False
Feb 23, 2013 at 06:59 PM
/api/public/snipt/1115/
tar-and-zip-an-entire-folder
<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>tar cvzfp site.tgz /home/user/public_html </span></pre></div> </td></tr></table>
backup, bash, linux, tar, zip

Bash

accessing args from previous command

1
2
3
ls -alrt /tmp /var/ /usr
cd !:2
-> cd /tmp
https://snipt.net/embed/41b4e5329cc9c53b50317fdae5da61e4/
/raw/41b4e5329cc9c53b50317fdae5da61e4/
41b4e5329cc9c53b50317fdae5da61e4
bash
Bash
3
2019-07-13T01:12:18
True
False
False
/api/public/snipt/967/
accessing-args-from-previous-command
<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>ls -alrt /tmp /var/ /usr </span><span id="L-2"><a name="L-2"></a><span class="nb">cd</span> !:2 </span><span id="L-3"><a name="L-3"></a>-&gt; <span class="nb">cd</span> /tmp </span></pre></div> </td></tr></table>
bash, shell

Bash

shell substitution

1
2
3
cl config.ini config.ini.bak
^cl^cp
!!:gs/cl/cp/
https://snipt.net/embed/d9b0ea9425b7633b25d6e597bd46baa4/
/raw/d9b0ea9425b7633b25d6e597bd46baa4/
d9b0ea9425b7633b25d6e597bd46baa4
bash
Bash
3
2019-07-18T15:03:18
True
False
False
/api/public/snipt/966/
shell-substitution
<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>cl config.ini config.ini.bak </span><span id="L-2"><a name="L-2"></a>^cl^cp </span><span id="L-3"><a name="L-3"></a>!!:gs/cl/cp/ </span></pre></div> </td></tr></table>
bash, shell

Bash

search in files

grep term
https://snipt.net/embed/de69be05b80258e72563ca29a1a3267b/
/raw/de69be05b80258e72563ca29a1a3267b/
de69be05b80258e72563ca29a1a3267b
bash
Bash
1
2019-07-19T03:43:32
True
False
False
/api/public/snipt/917/
search-in-files
<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>grep term </span></pre></div> </td></tr></table>
bash, grep

Bash

Looping through files in Bash

1
2
3
4
for FILENAME in /home/user/*.txt
do
    echo "Filename: $FILENAME"
done
https://snipt.net/embed/a2d4c41322df9e95425c295ca662fc9d/
/raw/a2d4c41322df9e95425c295ca662fc9d/
a2d4c41322df9e95425c295ca662fc9d
bash
Bash
5
2019-07-21T02:41:49
True
False
False
/api/public/snipt/892/
looping-through-files-in-bash
<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></span><span id="L-1"><a name="L-1"></a><span class="k">for</span> FILENAME in /home/user/*.txt </span><span id="L-2"><a name="L-2"></a><span class="k">do</span> </span><span id="L-3"><a name="L-3"></a> <span class="nb">echo</span> <span class="s2">&quot;Filename: </span><span class="nv">$FILENAME</span><span class="s2">&quot;</span> </span><span id="L-4"><a name="L-4"></a><span class="k">done</span> </span></pre></div> </td></tr></table>
bash, filename, loop

Bash

See your most frequently used commands

history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr
https://snipt.net/embed/42322c44bfa45f12db044d29d321a2b4/
/raw/42322c44bfa45f12db044d29d321a2b4/
42322c44bfa45f12db044d29d321a2b4
bash
Bash
2
2019-07-06T20:31:22
True
False
False
/api/public/snipt/876/
see-your-most-frequently-used-commands
<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="nb">history</span> <span class="p">|</span> awk <span class="s1">&#39;{print $2}&#39;</span> <span class="p">|</span> awk <span class="s1">&#39;BEGIN {FS=&quot;|&quot;}{print $1}&#39;</span> <span class="p">|</span> sort <span class="p">|</span> uniq -c <span class="p">|</span> sort -n <span class="p">|</span> tail <span class="p">|</span> sort -nr </span></pre></div> </td></tr></table>
awk, bash, history, linux, unix

Bash

Find recent large files

find . -size +10000000c -newerct '14 days ago'
https://snipt.net/embed/f7ca1a19c43e9f0024f78a03a3835688/
/raw/f7ca1a19c43e9f0024f78a03a3835688/
f7ca1a19c43e9f0024f78a03a3835688
bash
Bash
1
2019-07-21T03:46:06
True
False
False
/api/public/snipt/866/
find-recent-large-files
<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>find . -size +10000000c -newerct <span class="s1">&#39;14 days ago&#39;</span> </span></pre></div> </td></tr></table>
bash