snipt

Ctrl+h for KB shortcuts

Bash

find and delete

find . -name "FILE-TO-FIND"-exec rm -rf {} \;
https://snippets.siftie.com/embed/1967e81f57d8cda3f1740bc4d75ea360/
/raw/1967e81f57d8cda3f1740bc4d75ea360/
1967e81f57d8cda3f1740bc4d75ea360
bash
Bash
1
2019-03-17T17:15:10
True
False
False
/api/public/snipt/12527/
find-and-delete
<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 <span class="s2">&quot;FILE-TO-FIND&quot;</span>-exec rm -rf <span class="o">{}</span> <span class="se">\;</span> </span></pre></div> </td></tr></table>
bash, unix

Bash

Find with grep

 find ./ -name *.* -exec grep -i "something" '{}' \; -print
https://snippets.siftie.com/embed/5211293736ee91788e2826c567cc7b15/
/raw/5211293736ee91788e2826c567cc7b15/
5211293736ee91788e2826c567cc7b15
bash
Bash
1
2019-02-22T14:08:41
True
False
False
/api/public/snipt/6421/
find-with-grep
<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 *.* -exec grep -i <span class="s2">&quot;something&quot;</span> <span class="s1">&#39;{}&#39;</span> <span class="se">\;</span> -print </span></pre></div> </td></tr></table>
unix

Bash

Simple bash for loop

for i in `ls`; do echo $i; done
https://snippets.siftie.com/embed/34e38b8afee3d37d49925f59392f6f2d/
/raw/34e38b8afee3d37d49925f59392f6f2d/
34e38b8afee3d37d49925f59392f6f2d
bash
Bash
1
2019-03-07T23:17:15
True
False
False
/api/public/snipt/2920/
simple-bash-for-loop
<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><span class="k">for</span> i in <span class="sb">`</span>ls<span class="sb">`</span><span class="p">;</span> <span class="k">do</span> <span class="nb">echo</span> <span class="nv">$i</span><span class="p">;</span> <span class="k">done</span> </span></pre></div> </td></tr></table>
bash, unix