snipt

Ctrl+h for KB shortcuts
Sign up for : store and share your own code snippets.
#110730

Text only

Swapping file names Using a bash function

1
2
3
4
function swap_file() {
    TMP_NAME="TMP_$RANDOM"
    mv "$1" "/tmp/$TMP_NAME" && mv "$2" "$1" && mv "/tmp/$TMP_NAME" "$2"
}
https://snipt.net/embed/dd5d1ca34c5cad8fc47329dad6281672/
https://snipt.net/raw/dd5d1ca34c5cad8fc47329dad6281672/
dd5d1ca34c5cad8fc47329dad6281672
text
Text only
4
2015-07-02T00:32:47
True
True
Feb 04, 2014 at 05:54 AM
/api/public/snipt/110730/
swapping-file-names-using-a-bash-function
<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 id="L-1"><a name="L-1"></a>function swap_file() { </span><span id="L-2"><a name="L-2"></a> TMP_NAME=&quot;TMP_$RANDOM&quot; </span><span id="L-3"><a name="L-3"></a> mv &quot;$1&quot; &quot;/tmp/$TMP_NAME&quot; &amp;&amp; mv &quot;$2&quot; &quot;$1&quot; &amp;&amp; mv &quot;/tmp/$TMP_NAME&quot; &quot;$2&quot; </span><span id="L-4"><a name="L-4"></a>} </span></pre></div> </td></tr></table>
bash
#106483

Bash

workaround failed 'brew update'

1
2
3
4
cd `brew --prefix`
git remote add origin https://github.com/mxcl/homebrew.git
git fetch origin
git reset --hard origin/master
https://snipt.net/embed/950cad4515e75bcf1279170f5214aba4/
https://snipt.net/raw/950cad4515e75bcf1279170f5214aba4/
950cad4515e75bcf1279170f5214aba4
bash
Bash
4
2015-07-02T00:32:48
True
False
Jan 17, 2014 at 03:28 AM
/api/public/snipt/106483/
workaround-failed-brew-update
<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 id="L-1"><a name="L-1"></a><span class="nb">cd</span> <span class="sb">`</span>brew --prefix<span class="sb">`</span> </span><span id="L-2"><a name="L-2"></a>git remote add origin https://github.com/mxcl/homebrew.git </span><span id="L-3"><a name="L-3"></a>git fetch origin </span><span id="L-4"><a name="L-4"></a>git reset --hard origin/master </span></pre></div> </td></tr></table>
bash, brew, git
#103904

Bash

Copy directory structure

cd /source/dir
( cd /destination/dir/; sudo find . -depth -type d ! -name . -print0 ) | xargs -0 mkdir -p
https://snipt.net/embed/218cdc121a23332b57466b390fd9d4b6/
https://snipt.net/raw/218cdc121a23332b57466b390fd9d4b6/
218cdc121a23332b57466b390fd9d4b6
bash
Bash
2
2015-07-02T00:32:48
True
False
/api/public/snipt/103904/
copy-directory-structure
<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 id="L-1"><a name="L-1"></a><span class="nb">cd</span> /source/dir </span><span id="L-2"><a name="L-2"></a><span class="o">(</span> <span class="nb">cd</span> /destination/dir/<span class="p">;</span> sudo find . -depth -type d ! -name . -print0 <span class="o">)</span> <span class="p">|</span> xargs -0 mkdir -p </span></pre></div> </td></tr></table>
bash, mass
#97932

Bash

Watch a real 3D movie in 2D with MPlayer

mplayer <VIDEO_FILE> -vo gl:stereo=3
https://snipt.net/embed/11c192fc1ffbad4aff016669c8578b23/
https://snipt.net/raw/11c192fc1ffbad4aff016669c8578b23/
11c192fc1ffbad4aff016669c8578b23
bash
Bash
1
2015-07-02T00:41:30
True
False
Dec 02, 2013 at 07:48 AM
/api/public/snipt/97932/
watch-a-real-3d-movie-in-2d-with-mplayer
<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>mplayer &lt;VIDEO_FILE&gt; -vo gl:stereo<span class="o">=</span>3 </span></pre></div> </td></tr></table>
2d, 3d, bash, movie, mplayer, video
#93399

Bash

Terminal check file permissions

stat -c %A fileNameToCheck
https://snipt.net/embed/69255e3c3dbfa946d35d09d6c7a914d2/
https://snipt.net/raw/69255e3c3dbfa946d35d09d6c7a914d2/
69255e3c3dbfa946d35d09d6c7a914d2
bash
Bash
1
2015-07-02T00:32:47
True
False
Nov 11, 2013 at 05:32 AM
/api/public/snipt/93399/
terminal-check-file-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 id="L-1"><a name="L-1"></a>stat -c %A fileNameToCheck </span></pre></div> </td></tr></table>
bash, terminal
#88441

Bash

Show user certificates stored in Mozilla Firefox

1
2
3
certutil -K -d <PROFILE_DIRECTORY>
modutil -list -dbdir <PROFILE_DIRECTORY>
modutil -rawlist -dbdir <PROFILE_DIRECTORY>
https://snipt.net/embed/c736d144c2a86b43bf9e4695669ebd74/
https://snipt.net/raw/c736d144c2a86b43bf9e4695669ebd74/
c736d144c2a86b43bf9e4695669ebd74
bash
Bash
3
2015-07-02T00:32:47
True
False
Oct 18, 2013 at 03:09 AM
/api/public/snipt/88441/
show-user-certificates-stored-in-mozilla-firefox
<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 id="L-1"><a name="L-1"></a>certutil -K -d &lt;PROFILE_DIRECTORY&gt; </span><span id="L-2"><a name="L-2"></a>modutil -list -dbdir &lt;PROFILE_DIRECTORY&gt; </span><span id="L-3"><a name="L-3"></a>modutil -rawlist -dbdir &lt;PROFILE_DIRECTORY&gt; </span></pre></div> </td></tr></table>
bash, certificates, certutil, firefox, modutil, mozilla
Copyrighted, illegal, or inappropriate content? Email nick@snipt.net.