{"id":99,"date":"2010-04-12T16:01:29","date_gmt":"2010-04-12T16:01:29","guid":{"rendered":"https:\/\/www.taywa.ch\/blog\/?p=99"},"modified":"2011-06-27T14:37:10","modified_gmt":"2011-06-27T14:37:10","slug":"unix-shell-befehle-spickzettel","status":"publish","type":"post","link":"https:\/\/www.taywa.ch\/blog\/ubuntu\/unix-shell-befehle-spickzettel\/","title":{"rendered":"unix bash-shell befehle spickzettel"},"content":{"rendered":"<p>bash-shell befehle, die immer wieder gebraucht werden:<\/p>\n<p>dns eintr\u00e4ge testen, ip von server sehen:<\/p>\n<div class=\"bash dean_ch\"><span class=\"co0\"># ip und aliase zeigen<\/span><br \/>\nhost www.meinedomain.ch<br \/>\n<span class=\"co0\"># nach ip aufl\u00f6sen \u00fcber bestimmten dns<\/span><br \/>\nhost www.domain.ch ns1.taywa.net<\/div>\n<p>tar.gz dateien packen\/anlegen bzw. entpacken:<\/p>\n<div class=\"bash dean_ch\"><span class=\"co0\"># rechte und symlinks bleiben beim packen\/entpacken erhalten<\/span><br \/>\n<span class=\"co0\"># <\/span><br \/>\n<span class=\"co0\"># komprimieren (.tgz oder .tar.gz &#8211; eigentlich dasselbe):<\/span><br \/>\n<span class=\"kw2\">tar<\/span> czfv dateiname.tgz ordnername<span class=\"sy0\">\/*<\/span><br \/>\n<span class=\"co0\">#<\/span><br \/>\n<span class=\"co0\"># entpacken:<\/span><br \/>\n<span class=\"kw2\">tar<\/span> xfvz dateiname.tar.gz<\/div>\n<p>symbolic link anlegen:<\/p>\n<div class=\"bash dean_ch\"><span class=\"co0\"># wenn &quot;linkname&quot; nicht angegeben wird,<\/span><br \/>\n<span class=\"co0\"># bekommt der link den namen des zielordners <\/span><br \/>\n<span class=\"kw2\">ln<\/span> <span class=\"re5\">-s<\/span> pfad<span class=\"sy0\">\/<\/span>zum<span class=\"sy0\">\/<\/span>ziel linkname<\/div>\n<p>rechte rekursiv \u00e4ndern:<\/p>\n<div class=\"bash dean_ch\"><span class=\"co0\"># rekursiv &nbsp;f\u00fcr user(owner), gruppe und others schreibrechte hinzuf\u00fcgen<\/span><br \/>\n<span class=\"kw2\">chmod<\/span> <span class=\"re5\">-R<\/span> ugo+<span class=\"kw2\">w<\/span> <span class=\"sy0\">*<\/span><br \/>\n<span class=\"co0\"># gruppe und others schreibrechte wegnehmen:<\/span><br \/>\n<span class=\"kw2\">chmod<\/span> go-w ordnername<\/div>\n<p>shellscript &#8222;for&#8220; schlaufe mit gefundenen dateinamen:<\/p>\n<div class=\"bash dean_ch\"><span class=\"co0\"># bilder mit mask.png maskieren und in ordner &quot;res&quot; speichern:<\/span><br \/>\n<span class=\"kw1\">for<\/span> i <span class=\"kw1\">in<\/span> $<span class=\"br0\">&#40;<\/span><span class=\"kw2\">ls<\/span> <span class=\"sy0\">*<\/span>.png<span class=\"br0\">&#41;<\/span>; <span class=\"kw1\">do<\/span> composite <span class=\"re5\">-compose<\/span> CopyOpacity ..<span class=\"sy0\">\/<\/span>mask.png <span class=\"re1\">$i<\/span> res<span class=\"sy0\">\/<\/span><span class=\"re1\">$i<\/span> ; <span class=\"kw1\">done<\/span><\/div>\n<p>rekursiv string in dateien suchen:<\/p>\n<div class=\"bash dean_ch\"><span class=\"co0\"># wird nur * angegeben, sucht es im aktuellen verzeichniss:<\/span><br \/>\n<span class=\"kw2\">grep<\/span> <span class=\"re5\">-R<\/span> <span class=\"st_h\">&#8217;string&#8216;<\/span> <span class=\"sy0\">\/<\/span>path<span class=\"sy0\">\/<\/span>to<span class=\"sy0\">\/<\/span>files<span class=\"sy0\">\/*<\/span><\/div>\n<p>befehl rekursiv auf mit regex ausgew\u00e4hlte dateien anwenden (mit dem vorteil, erstmal einen dry-run ohne befehl zu machen zu k\u00f6nnen um die regex zu testen):<\/p>\n<div class=\"bash dean_ch\"><span class=\"co0\"># find .&nbsp; &nbsp; &nbsp; &nbsp; findet alles rekursiv<\/span><br \/>\n<span class=\"co0\"># grep&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; regular expression f\u00fcr dateinamen: ende$ &nbsp; ^beginn<\/span><br \/>\n<span class=\"co0\"># xargs befehl&nbsp; nimmt den pfad als parameter f\u00fcr den befehl<\/span><br \/>\n<span class=\"kw2\">find<\/span> . <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> ext$ <span class=\"sy0\">|<\/span> <span class=\"kw2\">xargs<\/span> <span class=\"kw2\">rm<\/span><\/div>\n","protected":false},"excerpt":{"rendered":"<p>bash-shell befehle, die immer wieder gebraucht werden: dns eintr\u00e4ge testen, ip von server sehen: # ip und aliase zeigen host www.meinedomain.ch # nach ip aufl\u00f6sen \u00fcber bestimmten dns host www.domain.ch ns1.taywa.net tar.gz dateien packen\/anlegen bzw. entpacken: # rechte und symlinks bleiben beim packen\/entpacken erhalten # # komprimieren (.tgz oder .tar.gz &#8211; eigentlich dasselbe): tar czfv<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[56],"class_list":["post-99","post","type-post","status-publish","format-standard","hentry","category-ubuntu","tag-shell"],"_links":{"self":[{"href":"https:\/\/www.taywa.ch\/blog\/wp-json\/wp\/v2\/posts\/99","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.taywa.ch\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.taywa.ch\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.taywa.ch\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.taywa.ch\/blog\/wp-json\/wp\/v2\/comments?post=99"}],"version-history":[{"count":21,"href":"https:\/\/www.taywa.ch\/blog\/wp-json\/wp\/v2\/posts\/99\/revisions"}],"predecessor-version":[{"id":101,"href":"https:\/\/www.taywa.ch\/blog\/wp-json\/wp\/v2\/posts\/99\/revisions\/101"}],"wp:attachment":[{"href":"https:\/\/www.taywa.ch\/blog\/wp-json\/wp\/v2\/media?parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.taywa.ch\/blog\/wp-json\/wp\/v2\/categories?post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.taywa.ch\/blog\/wp-json\/wp\/v2\/tags?post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}