snipt

Ctrl+h for KB shortcuts

Shell Session

Mount remote server drive with OSXFUSE and ssh

sshfs [-p PORT-NUMBER] USERNAME@MYDOMAIN.com:/remote/path /Local/Path/to/an/existing/folder
https://snipt.net/embed/178080a463bae7bdfcf47a9de1f1fd0b/
https://snipt.net/raw/178080a463bae7bdfcf47a9de1f1fd0b/
178080a463bae7bdfcf47a9de1f1fd0b
shell-session
Shell Session
1
2016-09-25T21:17:38
True
False
False
Feb 05, 2014 at 09:52 AM
/api/public/snipt/111141/
mount-remote-server-drive-with-osxfuse-and-ssh
<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="go">sshfs [-p PORT-NUMBER] USERNAME@MYDOMAIN.com:/remote/path /Local/Path/to/an/existing/folder</span> </span></pre></div> </td></tr></table>
commandline, mac, server, ssh, terminal

Bash

List Largest Files

du -a /var | sort -n -r | head -n 10
https://snipt.net/embed/4c08ac60195c82259f5ff0ea83699187/
https://snipt.net/raw/4c08ac60195c82259f5ff0ea83699187/
4c08ac60195c82259f5ff0ea83699187
bash
Bash
1
2016-09-22T02:47:06
True
False
False
/api/public/snipt/38235/
list-largest-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 id="L-1"><a name="L-1"></a>du -a /var <span class="p">|</span> sort -n -r <span class="p">|</span> head -n 10 </span></pre></div> </td></tr></table>
bash, commandline

Python

Show python lib folder

python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
https://snipt.net/embed/20466cfca66a21e37b54fbc72d3a99d4/
https://snipt.net/raw/20466cfca66a21e37b54fbc72d3a99d4/
20466cfca66a21e37b54fbc72d3a99d4
python
Python
2
2016-09-24T17:00:59
True
False
False
/api/public/snipt/25389/
show-python-lib-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 id="L-1"><a name="L-1"></a><span class="n">python</span> <span class="o">-</span><span class="n">c</span> <span class="s">&quot;from distutils.sysconfig import get_python_lib; print get_python_lib()&quot;</span> </span></pre></div> </td></tr></table>
commandline, config, environment, folder, path, python

Bash

Batch rename filename from foo*.jpg to bar*.jpg

ls foo*.jpg | awk '{print("mv "$1" "$1)}' | sed 's/foo/bar/2' | /bin/sh
https://snipt.net/embed/0593639bfa2991bb40f9358ecdb2e85c/
https://snipt.net/raw/0593639bfa2991bb40f9358ecdb2e85c/
0593639bfa2991bb40f9358ecdb2e85c
bash
Bash
1
2016-09-22T02:47:12
True
False
False
/api/public/snipt/24178/
batch-rename-filename-from-foojpg-to-barjpg
<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>ls foo*.jpg <span class="p">|</span> awk <span class="s1">&#39;{print(&quot;mv &quot;$1&quot; &quot;$1)}&#39;</span> <span class="p">|</span> sed <span class="s1">&#39;s/foo/bar/2&#39;</span> <span class="p">|</span> /bin/sh </span></pre></div> </td></tr></table>
bash, commandline, one-liner

PHP

Random Shuffle Lines in a file

php -r '$a=file("myfile.txt"); shuffle($a); foreach($a as $v) {echo $v;}'
https://snipt.net/embed/43534d292c9e49823ba6337679a99c52/
https://snipt.net/raw/43534d292c9e49823ba6337679a99c52/
43534d292c9e49823ba6337679a99c52
php
PHP
1
2016-09-22T02:47:19
True
False
False
/api/public/snipt/21541/
random-shuffle-lines-in-a-file
<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="x">php -r &#39;$a=file(&quot;myfile.txt&quot;); shuffle($a); foreach($a as $v) {echo $v;}&#39;</span> </span></pre></div> </td></tr></table>
commandline, one-liner, php

Bash

one liner recursive execute command on directory of files

#> for f in /path/to/*;do yourcommand $f;done
https://snipt.net/embed/f6b236c4c1afe16b83af27054f7bbc4f/
https://snipt.net/raw/f6b236c4c1afe16b83af27054f7bbc4f/
f6b236c4c1afe16b83af27054f7bbc4f
bash
Bash
1
2016-09-22T00:48:20
True
False
False
/api/public/snipt/21365/
one-liner-recursive-execute-command-on-directory-of-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 id="L-1"><a name="L-1"></a><span class="c">#&gt; for f in /path/to/*;do yourcommand $f;done</span> </span></pre></div> </td></tr></table>
"os x", bash, commandline, linux, one-liner

Perl

windows path item per line

C:\> path | perl -F/[;=]/ -ane "$,=qq{\n};shift@F;print@F"
https://snipt.net/embed/78da6676829619f51d712c8c339e0f6f/
https://snipt.net/raw/78da6676829619f51d712c8c339e0f6f/
78da6676829619f51d712c8c339e0f6f
perl
Perl
1
2016-09-22T02:47:26
True
False
False
/api/public/snipt/6281/
windows-path-item-per-line
<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="n">C:</span><span class="o">\&gt;</span> <span class="n">path</span> <span class="o">|</span> <span class="n">perl</span> <span class="o">-</span><span class="n">F</span><span class="sr">/[;=]/</span> <span class="o">-</span><span class="n">ane</span> <span class="s">&quot;$,=qq{\n};shift@F;print@F&quot;</span> </span></pre></div> </td></tr></table>
commandline, perl, windows

Bash

commandline search server logs for activity in time frame

1
2
3
4
5
# following date/time is day/month/year:hour:min:sec
# as in 02/Feb/2009:23:59:59
# leave off more for a broader range like:
# 02/Feb/2009:0   ...here's mine:   [your structure may vary]
grep -rn "26/Sep/2008:01:" /usr/local/apache/domlogs/*
https://snipt.net/embed/e1d88fde101d30ce6e6fe8f747167b5c/
https://snipt.net/raw/e1d88fde101d30ce6e6fe8f747167b5c/
e1d88fde101d30ce6e6fe8f747167b5c
bash
Bash
5
2016-09-22T00:49:45
True
False
False
/api/public/snipt/3179/
commandline-search-server-logs-for-activity-in-time-frame
<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></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c"># following date/time is day/month/year:hour:min:sec</span> </span><span id="L-2"><a name="L-2"></a><span class="c"># as in 02/Feb/2009:23:59:59</span> </span><span id="L-3"><a name="L-3"></a><span class="c"># leave off more for a broader range like:</span> </span><span id="L-4"><a name="L-4"></a><span class="c"># 02/Feb/2009:0 ...here&#39;s mine: [your structure may vary]</span> </span><span id="L-5"><a name="L-5"></a>grep -rn <span class="s2">&quot;26/Sep/2008:01:&quot;</span> /usr/local/apache/domlogs/* </span></pre></div> </td></tr></table>
commandline, date, grep, linux, logs, range, server, web, webserver
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.