snipt

Ctrl+h for KB shortcuts

Bash

awk example

$ cat file.txt | awk '// {print "cp -R "$1" backups/\nwait"}' > backup.sh
https://snipt.net/embed/1c9b1c378b8b7ad11ff2f0f0979d9822/
/raw/1c9b1c378b8b7ad11ff2f0f0979d9822/
1c9b1c378b8b7ad11ff2f0f0979d9822
bash
Bash
1
2019-06-15T14:04:18
True
False
False
/api/public/snipt/13986/
awk-example
<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>$ cat file.txt <span class="p">|</span> awk <span class="s1">&#39;// {print &quot;cp -R &quot;$1&quot; backups/\nwait&quot;}&#39;</span> &gt; backup.sh </span></pre></div> </td></tr></table>
awk, linux, string, text, unix

Bash

add string to top of text file

$ sed -e '1i\#!/bin/bash' -i backup.sh
https://snipt.net/embed/d7deda70543d69f572cda5b21d46807e/
/raw/d7deda70543d69f572cda5b21d46807e/
d7deda70543d69f572cda5b21d46807e
bash
Bash
1
2019-06-23T02:55:05
True
False
False
/api/public/snipt/13984/
add-string-to-top-of-text-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></span><span id="L-1"><a name="L-1"></a>$ sed -e <span class="s1">&#39;1i\#!/bin/bash&#39;</span> -i backup.sh </span></pre></div> </td></tr></table>
add, bash, linux, script, string

ActionScript 3

RegEx - Find and Replace

1
2
3
4
5
var str:String = "Hello World!";

var myPattern:RegExp = /Hello/g; //regex to remove all hellos
str = str.replace(myPattern, "Goodbye");
trace(str); // Goodbye World!
https://snipt.net/embed/686b16894fc75ddb127efd92c4d92ca9/
/raw/686b16894fc75ddb127efd92c4d92ca9/
686b16894fc75ddb127efd92c4d92ca9
as3
ActionScript 3
7
2019-06-20T16:17:42
True
False
False
/api/public/snipt/13446/
regex-find-and-replace
<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="kd">var</span> <span class="n">str</span><span class="p">:</span><span class="kt">String</span> <span class="o">=</span> <span class="s2">&quot;Hello World!&quot;</span><span class="o">;</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="kd">var</span> <span class="n">myPattern</span><span class="p">:</span><span class="kt">RegExp</span> <span class="o">=</span> <span class="sr">/Hello/g; //</span><span class="n">regex</span> <span class="n">to</span> <span class="n">remove</span> <span class="n">all</span> <span class="n">hellos</span> </span><span id="L-4"><a name="L-4"></a><span class="n">str</span> <span class="o">=</span> <span class="n">str</span><span class="o">.</span><span class="na">replace</span><span class="o">(</span><span class="n">myPattern</span><span class="o">,</span> <span class="s2">&quot;Goodbye&quot;</span><span class="o">);</span> </span><span id="L-5"><a name="L-5"></a><span class="nf">trace</span><span class="o">(</span><span class="n">str</span><span class="o">);</span> <span class="c1">// Goodbye World!</span> </span></pre></div> </td></tr></table>
as3, find, flash, regex, replace, string