[linux][bash][scripting][Notizen] Eine nützliche Erweiterung des find-Befehls... (multiple commands in find) by klippengeist

View this thread on steempeak.com
· @klippengeist ·
$0.12
[linux][bash][scripting][Notizen] Eine nützliche Erweiterung des find-Befehls... (multiple commands in find)
<h1>Meine Bash-Scripting Notizen... Stay updated & follow me on steemit: free images, art, linux, seo & more</h1>
<p>Ich muß mal anfangen, meine besten Scripting-Fundstücke irgendwo außerhalb meiner Festplatten abzulegen... und wo wäre ein besserer Platz als hier in der Blockchain? ~:-)</p>
<h2>Den find-Befehl sinnvoll erweitern</h2>
<p>Ich habe in den letzten zwei Wochen mehrfach versucht, in <a href="https://linux.die.net/man/1/find">find</a> die curly brackets <b>{&nbsp;}</b> auszutricksen, um deren Inhalt (den Dateinamen) nach meinen Wünschen anzupassen. Ich dachte tatsächlich, daß die brackets einfach irgendeine Variable wären, auf die ich nach Belieben zugreifen könnte. Der <a href="https://linux.die.net/man/1/find">find</a>-Befehl sieht auf den ersten Blick ja auch irgendwie unspektakulär aus:</p>
<blockquote>
find . -name "*.jpg" -exec irgendeinKommando {} \;
</blockquote>
<p>Da muß sich doch was bohnern lassen? Falsch gedacht...<br />
<b>---pause---</b><br />
(Inzwischen bin ich von dieser Krankheit geheilt... jaja... ich weiß...<br />
<a href="https://de.wiktionary.org/wiki/errare_humanum_est">Errare humanum est</a>, <a href="https://de.wiktionary.org/wiki/Asche_aufs_Haupt_streuen">Asche auf mein Haupt</a> &nbsp; <a href="https://de.wiktionary.org/wiki/etc._pp.">etc. pp.</a>).</p>
<p>Der Beitrag eines Forenten</p>
<blockquote>[...]The curly braces will be replaced by the results of the find command[...] (<a href="https://unix.stackexchange.com/questions/202391/understanding-find1s-exec-option-curly-braces-plus-sign">Quelle</a>)</blockquote>
<p>hat mich zum Umdenken bewegt: <i>Dat funzt net</i>. Aber geht dann möglicherweise etwas anderes? ~:-)</p>
<p>Und tatsächlich: Ich habe die Suchparameter der <a href="https://www.wolframalpha.com/">Suchmaschine meines Vertrauens</a> *hüstel* ein wenig angepaßt und <b>TADAA...</b></p>
<p>In <a href="https://stackoverflow.com/a/46020381">diesem Forumsbeitrag</a> bei <a href="https://stackoverflow.com">stackoverflow</a> bin ich fündig geworden:</p>
<blockquote>
multiple_cmd() {<br />
&nbsp;&nbsp;&nbsp;&nbsp;<i>hier die coolsten Kommandos</i><br />
};<br />
export -f multiple_cmd;<br />
find *.txt -exec bash -c 'multiple_cmd "$0"' {&nbsp;} \;<br />
&nbsp;&nbsp;&nbsp;&nbsp;"multiple_cmd()" - is a function<br />
&nbsp;&nbsp;&nbsp;&nbsp;"export -f multiple_cmd" - will export it so any other subshell can see it<br />
&nbsp;&nbsp;&nbsp;&nbsp;"find *.txt -exec bash -c 'multiple_cmd "$0"' {} \;" - find that will execute the function on your example<br />
</blockquote>
<p>Man startet eine Subshell, in der man die lustigsten Dinge vorbereiten kann, die dann auf die Dateien angewendet werden, die <a href="https://linux.die.net/man/1/find">find</a> liefert.</p>
<p>Ich nutze diese Möglichkeit beispielsweise, um Metadaten von meinen Fotos auf multilingual aufbereitete Derivate zu transferieren (darüber an anderer Stelle mehr...).</p>
<p>Nutzt schon jemand von Euch dieses Spielzeug? ~:-)</p>
<p>Bis Dennis</p>

![screenshot. 2018-06-19 01-45-25.png](https://cdn.steemitimages.com/DQmQAKM9RPnDSnggYnaQNv86dp39sgmSRCt9BRVnWNda1F9/screenshot.%202018-06-19%2001-45-25.png)
<p><b>Screenshot:</b> Mit freundlicher Genehmigung meiner <a href="https://de.wikipedia.org/wiki/Screenshot#PC_(mit_Tastatur)">Computertastatur</a><br />
<b>Bildlizenz:</b> CC0 - Public Domain bzw. drauf geschissen</p>
<hr />
<p><b><i>(-:~ ...memento mori... ~:-)</i></b></p>
👍  , , , , ,
properties (23)
post_id53,499,249
authorklippengeist
permlinklinux-bash-scripting-notizen-eine-nuetzliche-erweiterung-des-find-befehls-multiple-commands-in-find
categorydeutsch
json_metadata"{"links": ["https://linux.die.net/man/1/find", "https://de.wiktionary.org/wiki/errare_humanum_est", "https://de.wiktionary.org/wiki/Asche_aufs_Haupt_streuen", "https://de.wiktionary.org/wiki/etc._pp.", "https://unix.stackexchange.com/questions/202391/understanding-find1s-exec-option-curly-braces-plus-sign", "https://www.wolframalpha.com/", "https://stackoverflow.com/a/46020381", "https://stackoverflow.com", "https://de.wikipedia.org/wiki/Screenshot#PC_(mit_Tastatur)"], "app": "steemit/0.1", "image": ["https://cdn.steemitimages.com/DQmQAKM9RPnDSnggYnaQNv86dp39sgmSRCt9BRVnWNda1F9/screenshot.%202018-06-19%2001-45-25.png"], "tags": ["deutsch", "linux", "bash", "blog", "creativity"], "format": "markdown"}"
created2018-06-19 00:57:27
last_update2018-06-19 00:57:27
depth0
children1
net_rshares0
last_payout2018-06-26 00:57:27
cashout_time1969-12-31 23:59:59
total_payout_value0.092 SBD
curator_payout_value0.025 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length3,428
author_reputation1,055,196,478,890
root_title"[linux][bash][scripting][Notizen] Eine nützliche Erweiterung des find-Befehls... (multiple commands in find)"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (6)
@steemitboard ·
@klippengeist, thank you for supporting @steemitboard as a witness.

[![](https://steemitimages.com/70x70/http://steemitboard.com/notifications/supportboard.png)](http://steemitboard.com/@klippengeist) Here is a small present to show our gratitude
<sub>_Click on the badge to view your Board of Honor._</sub>

Once again, thanks for your support!

**Do not miss the [last post](https://steemit.com/steemitboard/@steemitboard/steemitboard-world-cup-contest-russia-vs-egypt) from @steemitboard!**
properties (22)
post_id53,501,979
authorsteemitboard
permlinksteemitboard-notify-klippengeist-20180619t013838000z
categorydeutsch
json_metadata"{"image": ["https://steemitboard.com/img/notify.png"]}"
created2018-06-19 01:38:36
last_update2018-06-19 01:38:36
depth1
children0
net_rshares0
last_payout2018-06-26 01:38:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length494
author_reputation38,705,954,145,809
root_title"[linux][bash][scripting][Notizen] Eine nützliche Erweiterung des find-Befehls... (multiple commands in find)"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000