snipt

Ctrl+h for KB shortcuts

Shell Session

Sub-matrix of aTSV file

1
2
3
# head -n ri+(rj-ri) file.tsv | cut -f ci-cj | tail -n rj-ri+1

head -n 4 tabella.tsv | cut -f 2- | tail -n 2
https://snipt.net/embed/a45e077ccdb088dd4b2a88d17591f85d/
https://snipt.net/raw/a45e077ccdb088dd4b2a88d17591f85d/
a45e077ccdb088dd4b2a88d17591f85d
shell-session
Shell Session
3
2016-09-22T11:33:55
True
False
False
/api/public/snipt/94047/
sub-matrix-of-atsv-file
<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><span class="go"># head -n ri+(rj-ri) file.tsv | cut -f ci-cj | tail -n rj-ri+1</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="go">head -n 4 tabella.tsv | cut -f 2- | tail -n 2</span> </span></pre></div> </td></tr></table>
Bash, Linux

Bash

Remove CTRL+M (or use dos2unix!)

1
2
3
sed -i 's/^M//g' input_file

where '^M' is entered as 'ctl-V' and 'ctl-M'
https://snipt.net/embed/fe3250f7b1f8aec105f4656e845fcc4e/
https://snipt.net/raw/fe3250f7b1f8aec105f4656e845fcc4e/
fe3250f7b1f8aec105f4656e845fcc4e
bash
Bash
3
2016-09-26T00:57:57
True
False
False
Sep 17, 2013 at 09:13 AM
/api/public/snipt/81460/
remove-ctrlm-or-use-dos2unix
<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>sed -i <span class="s1">&#39;s/^M//g&#39;</span> input_file </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>where <span class="s1">&#39;^M&#39;</span> is entered as <span class="s1">&#39;ctl-V&#39;</span> and <span class="s1">&#39;ctl-M&#39;</span> </span></pre></div> </td></tr></table>
Bash, Linux

Bash

Replace a string in files matching an expression (Linux)

grep -rl matchstring somedir/ | xargs sed -i 's/string1/string2/g'
https://snipt.net/embed/4f6466844c4730d19241219a35479517/
https://snipt.net/raw/4f6466844c4730d19241219a35479517/
4f6466844c4730d19241219a35479517
bash
Bash
1
2016-09-22T11:34:07
True
False
False
Mar 31, 2013 at 12:35 PM
/api/public/snipt/58596/
replace-a-string-in-files-matching-an-expression-linux
<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>grep -rl matchstring somedir/ <span class="p">|</span> xargs sed -i <span class="s1">&#39;s/string1/string2/g&#39;</span> </span></pre></div> </td></tr></table>
Bash, Linux

Bash

Enable backspace key in UNIX

1
2
3
4
5
stty erase ^?

# This is:

stty erase <hit-backspace-key> <enter>
https://snipt.net/embed/554655a591b893b31ebad05fa5ac4067/
https://snipt.net/raw/554655a591b893b31ebad05fa5ac4067/
554655a591b893b31ebad05fa5ac4067
bash
Bash
5
2016-09-22T11:34:15
True
False
False
Nov 11, 2012 at 11:17 PM
/api/public/snipt/50044/
enable-backspace-key-in-unix-1
<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>stty erase ^? </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="c"># This is:</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>stty erase &lt;hit-backspace-key&gt; &lt;enter&gt; </span></pre></div> </td></tr></table>
Bash, UNIX

Bash

Enable backspace key in UNIX

1
2
3
4
5
stty erase ^?

# This is:

stty erase <hit-backspace-key> <enter>
https://snipt.net/embed/c4f8d4371c357b1a2c65be84fd3e4845/
https://snipt.net/raw/c4f8d4371c357b1a2c65be84fd3e4845/
c4f8d4371c357b1a2c65be84fd3e4845
bash
Bash
5
2016-09-27T09:43:15
True
False
False
Nov 11, 2012 at 06:05 PM
/api/public/snipt/50036/
enable-backspace-key-in-unix
<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>stty erase ^? </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="c"># This is:</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>stty erase &lt;hit-backspace-key&gt; &lt;enter&gt; </span></pre></div> </td></tr></table>
Bash, Unix

Bash

Creating Symbolic link for Command Line

1
2
3
4
5
6
7
8
# You can change the 'PATHTOTOOL' and the 'PATHTOLINK', 
# to use this command for a variety of tools
# '-s' is used to create a symbolic link (http://en.wikipedia.org/wiki/Symbolic_link).

ln -s "PATHTOTOOL" PATHTOLINK 
 
# Example:
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
https://snipt.net/embed/229a3f21d47980e95c73f47c43b47c7d/
https://snipt.net/raw/229a3f21d47980e95c73f47c43b47c7d/
229a3f21d47980e95c73f47c43b47c7d
bash
Bash
8
2016-09-23T14:18:13
True
False
False
Oct 05, 2012 at 01:28 PM
/api/public/snipt/48140/
creating-symbolic-link-for-command-line
<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> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c"># You can change the &#39;PATHTOTOOL&#39; and the &#39;PATHTOLINK&#39;, </span> </span><span id="L-2"><a name="L-2"></a><span class="c"># to use this command for a variety of tools</span> </span><span id="L-3"><a name="L-3"></a><span class="c"># &#39;-s&#39; is used to create a symbolic link (http://en.wikipedia.org/wiki/Symbolic_link).</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>ln -s <span class="s2">&quot;PATHTOTOOL&quot;</span> PATHTOLINK </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a><span class="c"># Example:</span> </span><span id="L-8"><a name="L-8"></a>ln -s <span class="s2">&quot;/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl&quot;</span> /usr/local/bin/subl </span></pre></div> </td></tr></table>
"Command Line", "Symbolic Links", Bash
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.