Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Bash

kill process that contains string but not another string

1
2
3
4
5
# command line:
$ pgrep -lf "spork" | grep -v "tmux" | awk '{print $1}' | xargs kill -9

# via yaml or environment hostile to special characters (e.g., tmuxinator config)
$ kill -9 $(pgrep -lf "rails s" | grep -v "tmux" | cut -d " " -f1); rails s
https://snipt.net/embed/f78fdc50c4bf053db181c85adfb124ea/
https://snipt.net/raw/f78fdc50c4bf053db181c85adfb124ea/
f78fdc50c4bf053db181c85adfb124ea
bash
Bash
6
2016-12-04T05:28:12
True
False
False
Apr 11, 2013 at 12:51 AM
/api/public/snipt/56301/
kill-process-that-contains-string-but-not-another-string
<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></span><span id="L-1"><a name="L-1"></a><span class="c1"># command line:</span> </span><span id="L-2"><a name="L-2"></a>$ pgrep -lf <span class="s2">&quot;spork&quot;</span> <span class="p">|</span> grep -v <span class="s2">&quot;tmux&quot;</span> <span class="p">|</span> awk <span class="s1">&#39;{print $1}&#39;</span> <span class="p">|</span> xargs <span class="nb">kill</span> -9 </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1"># via yaml or environment hostile to special characters (e.g., tmuxinator config)</span> </span><span id="L-5"><a name="L-5"></a>$ <span class="nb">kill</span> -9 <span class="k">$(</span>pgrep -lf <span class="s2">&quot;rails s&quot;</span> <span class="p">|</span> grep -v <span class="s2">&quot;tmux&quot;</span> <span class="p">|</span> cut -d <span class="s2">&quot; &quot;</span> -f1<span class="k">)</span><span class="p">;</span> rails s </span></pre></div> </td></tr></table>
awk, cut, grep, kill, linux, pgrep, process, rails, server, spork, tmux, tmuxinator, ubuntu, xargs

Bash

find all pfam file and let them be parsed

find /Users/dgg32/Downloads/htcc2207 -iname "*pfam*" -print0 | xargs -0 python /Users/dgg32/Downloads/python/parse_pfam_sugar.py
https://snipt.net/embed/c18ffc45fd2a3fa9e5fbac9d01cb1bb5/
https://snipt.net/raw/c18ffc45fd2a3fa9e5fbac9d01cb1bb5/
c18ffc45fd2a3fa9e5fbac9d01cb1bb5
bash
Bash
1
2016-12-07T14:19:24
True
False
False
/api/public/snipt/31334/
find-all-pfam-file-and-let-them-be-parsed
<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 /Users/dgg32/Downloads/htcc2207 -iname <span class="s2">&quot;*pfam*&quot;</span> -print0 <span class="p">|</span> xargs -0 python /Users/dgg32/Downloads/python/parse_pfam_sugar.py </span></pre></div> </td></tr></table>
bash, find, xargs

Bash

Remove all deleted files from svn

svn status | grep ! | cut -d " " -f 8 | xargs -n 1 svn rm --force
https://snipt.net/embed/0c8f5b88be56994040bac6e8682ffb79/
https://snipt.net/raw/0c8f5b88be56994040bac6e8682ffb79/
0c8f5b88be56994040bac6e8682ffb79
bash
Bash
1
2016-12-11T03:28:56
True
False
False
/api/public/snipt/25517/
remove-all-deleted-files-from-svn
<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>svn status <span class="p">|</span> grep ! <span class="p">|</span> cut -d <span class="s2">&quot; &quot;</span> -f <span class="m">8</span> <span class="p">|</span> xargs -n <span class="m">1</span> svn rm --force </span></pre></div> </td></tr></table>
svn, xargs

Text only

kick off parallel processes using xargs

seq 10 20 | xargs -n 1 -P 5 sleep
https://snipt.net/embed/74d912798ceda9e93d29aff0edb24457/
https://snipt.net/raw/74d912798ceda9e93d29aff0edb24457/
74d912798ceda9e93d29aff0edb24457
text
Text only
1
2016-12-11T01:38:25
True
False
False
/api/public/snipt/5984/
kick-off-parallel-processes-using-xargs
<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>seq 10 20 | xargs -n 1 -P 5 sleep </span></pre></div> </td></tr></table>
parallel, xargs

Text only

xargs

find -name *.rb | xargs -i head -5 {}
https://snipt.net/embed/214643876998f13f31030a2dee349af1/
https://snipt.net/raw/214643876998f13f31030a2dee349af1/
214643876998f13f31030a2dee349af1
text
Text only
1
2016-12-11T01:38:29
True
False
False
/api/public/snipt/5437/
xargs
<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 *.rb | xargs -i head -5 {} </span></pre></div> </td></tr></table>
xargs

Bash

Convert XML docs to HTML

// Assumes xalan is installed on machine
find . -name '*.xml' | xargs -I PARAM java org.apache.xalan.xslt.Process -IN PARAM -XSL dir/file.xsl -OUT PARAM.html
https://snipt.net/embed/d84e5b7b4f2ad3870576c11fca85ee3c/
https://snipt.net/raw/d84e5b7b4f2ad3870576c11fca85ee3c/
d84e5b7b4f2ad3870576c11fca85ee3c
bash
Bash
2
2016-12-07T14:34:37
True
False
False
/api/public/snipt/3028/
convert-xml-docs-to-html
<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></span><span id="L-1"><a name="L-1"></a>// Assumes xalan is installed on machine </span><span id="L-2"><a name="L-2"></a>find . -name <span class="s1">&#39;*.xml&#39;</span> <span class="p">|</span> xargs -I PARAM java org.apache.xalan.xslt.Process -IN PARAM -XSL dir/file.xsl -OUT PARAM.html </span></pre></div> </td></tr></table>
find, html, xalan, xargs, xml, xsl, xslt
Copyrighted, illegal, or inappropriate content? Email [email protected].