snipt

Ctrl+h for KB shortcuts

Bash

Show me all files in ~ with wide open permissions

find ~ -perm 777 
https://snipt.net/embed/dcca60f3519252f5581d862f00f69e6a/
/raw/dcca60f3519252f5581d862f00f69e6a/
dcca60f3519252f5581d862f00f69e6a
bash
Bash
1
2019-06-03T00:27:35
True
False
False
/api/public/snipt/865/
show-me-all-files-in-with-wide-open-permissions
<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 ~ -perm <span class="m">777</span> </span></pre></div> </td></tr></table>
bash, find, linux, unix

Bash

Find all files in /etc owned by root that have been modified within the last day

find /etc -user root -mtime -1 
https://snipt.net/embed/99e0fa645d505a20db7337bbeef97ff2/
/raw/99e0fa645d505a20db7337bbeef97ff2/
99e0fa645d505a20db7337bbeef97ff2
bash
Bash
1
2019-06-17T13:57:51
True
False
False
/api/public/snipt/864/
find-all-files-in-etc-owned-by-root-that-have-been-modified-within-the-last-day
<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 /etc -user root -mtime -1 </span></pre></div> </td></tr></table>
bash, find, linux, unix

Bash

Find files greater than 1GB

find ~/Movies -size +1024M 
https://snipt.net/embed/449fb1ebcc5c64f0bfca791c4923c08b/
/raw/449fb1ebcc5c64f0bfca791c4923c08b/
449fb1ebcc5c64f0bfca791c4923c08b
bash
Bash
1
2019-06-17T04:46:51
True
False
False
/api/public/snipt/863/
find-files-greater-than-1gb
<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 ~/Movies -size +1024M </span></pre></div> </td></tr></table>
bash, find, linux, unix

Bash

Replace 'foo' with 'bar' in all PHP files in the folder. Recursive.

find . -name "*.php" -print | xargs sed -i 's/foo/bar/g'
https://snipt.net/embed/998916388c416be36115266cd25ea8aa/
/raw/998916388c416be36115266cd25ea8aa/
998916388c416be36115266cd25ea8aa
bash
Bash
1
2019-06-17T10:39:42
True
False
False
/api/public/snipt/862/
replace-foo-with-bar-in-all-php-files-in-the-folder-recursive
<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 . -name <span class="s2">&quot;*.php&quot;</span> -print <span class="p">|</span> xargs sed -i <span class="s1">&#39;s/foo/bar/g&#39;</span> </span></pre></div> </td></tr></table>
bash, find, php, replace, sed, unix

Bash

Replace 'foo' with 'bar' in all .txt files

sed -i 's/foo/bar/g' *.txt
https://snipt.net/embed/2bfbe2016a3acd22d5563728c8f99a8e/
/raw/2bfbe2016a3acd22d5563728c8f99a8e/
2bfbe2016a3acd22d5563728c8f99a8e
bash
Bash
1
2019-06-03T19:29:27
True
False
False
/api/public/snipt/861/
replace-foo-with-bar-in-all-txt-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>sed -i <span class="s1">&#39;s/foo/bar/g&#39;</span> *.txt </span></pre></div> </td></tr></table>
bash, find, linux, replace, sed, unix

Text only

start mysql on mac

1
2
3
4
5
6
7
sudo /usr/local/mysql/bin/safe_mysqld

sudo mkdir /var/mysql/

sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

export PATH="$PATH:/usr/local/mysql/bin"
https://snipt.net/embed/893ac8ab83c59ce42557d554e6aa3fda/
/raw/893ac8ab83c59ce42557d554e6aa3fda/
893ac8ab83c59ce42557d554e6aa3fda
text
Text only
7
2019-06-11T16:58:05
True
False
False
/api/public/snipt/855/
start-mysql-on-mac
<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> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>sudo /usr/local/mysql/bin/safe_mysqld </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>sudo mkdir /var/mysql/ </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a>export PATH=&quot;$PATH:/usr/local/mysql/bin&quot; </span></pre></div> </td></tr></table>
bash, mac, mysql, osx, server

Bash

grab your gps location from shell (uses your router's MAC address and looks it up on skyhook's database)

curl --header "Content-Type: text/xml" --data "<?xml version='1.0'?><LocationRQ xmlns='http://skyhookwireless.com/wps/2005' version='2.6' street-address-lookup='full'><authentication version='2.0'><simple><username>beta</username><realm>js.loki.com</realm></simple></authentication><access-point><mac>$(arp -a | awk '/[0-9a-f]:/ { gsub(/^0:|:0:/, "00:", $4); gsub(/:/, "", $4); print $4; exit; }')</mac><signal-strength>-50</signal-strength></access-point></LocationRQ>" https://api.skyhookwireless.com/wps2/location
https://snipt.net/embed/528ab0ceea2a9c7539b5480bddf05744/
/raw/528ab0ceea2a9c7539b5480bddf05744/
528ab0ceea2a9c7539b5480bddf05744
bash
Bash
1
2019-06-17T11:53:22
True
False
False
/api/public/snipt/846/
grab-your-gps-location-from-shell-uses-your-routers-mac-address-and-looks-it-up-on-skyhooks-database
<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>curl --header <span class="s2">&quot;Content-Type: text/xml&quot;</span> --data <span class="s2">&quot;&lt;?xml version=&#39;1.0&#39;?&gt;&lt;LocationRQ xmlns=&#39;http://skyhookwireless.com/wps/2005&#39; version=&#39;2.6&#39; street-address-lookup=&#39;full&#39;&gt;&lt;authentication version=&#39;2.0&#39;&gt;&lt;simple&gt;&lt;username&gt;beta&lt;/username&gt;&lt;realm&gt;js.loki.com&lt;/realm&gt;&lt;/simple&gt;&lt;/authentication&gt;&lt;access-point&gt;&lt;mac&gt;</span><span class="k">$(</span>arp -a <span class="p">|</span> awk <span class="s1">&#39;/[0-9a-f]:/ { gsub(/^0:|:0:/, &quot;00:&quot;, $4); gsub(/:/, &quot;&quot;, $4); print $4; exit; }&#39;</span><span class="k">)</span><span class="s2">&lt;/mac&gt;&lt;signal-strength&gt;-50&lt;/signal-strength&gt;&lt;/access-point&gt;&lt;/LocationRQ&gt;&quot;</span> https://api.skyhookwireless.com/wps2/location </span></pre></div> </td></tr></table>
arp, awk, bash, gps, skyhook

Bash

human readable size of directory

du -sh <dir>
https://snipt.net/embed/46812600d439c87d61acf0de8a1378cb/
/raw/46812600d439c87d61acf0de8a1378cb/
46812600d439c87d61acf0de8a1378cb
bash
Bash
1
2019-06-07T22:01:57
True
False
False
/api/public/snipt/673/
human-readable-size-of-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>du -sh &lt;dir&gt; </span></pre></div> </td></tr></table>
bash, linux, server

Bash

gives you a sorted list of the thigns using the most space

du -s * | sort -n
https://snipt.net/embed/53f475e722d056a863b5d1651c6d6845/
/raw/53f475e722d056a863b5d1651c6d6845/
53f475e722d056a863b5d1651c6d6845
bash
Bash
1
2019-06-08T20:42:00
True
False
False
/api/public/snipt/672/
gives-you-a-sorted-list-of-the-thigns-using-the-most-space
<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>du -s * <span class="p">|</span> sort -n </span></pre></div> </td></tr></table>
bash, linux, server