{"id":140,"date":"2015-05-10T17:09:41","date_gmt":"2015-05-10T11:39:41","guid":{"rendered":"https:\/\/bhuvan.wordpress.com\/?p=140"},"modified":"2023-10-15T11:41:19","modified_gmt":"2023-10-15T06:11:19","slug":"quick-tricks-on-shell","status":"publish","type":"post","link":"https:\/\/www.bhuvankrishna.in\/blog\/2015\/05\/10\/quick-tricks-on-shell\/","title":{"rendered":"Quick tricks on shell"},"content":{"rendered":"<p>I was working on a project that involves moving data from one point to other, it involves a verity of commands. I am listing some useful tricks.<\/p>\n<p>1. This script is a tiny script to compress, generate md5 and transfer any directory.<\/p>\n<p><code>tar cvJf $1.tar.xz $2;<br \/>\nmd5sum $1.tar.xz &gt; $1.md5sum<br \/>\nscp -i&lt;private key&gt; -P&lt;port&gt; $1.md5sum\u00a0&lt;user&gt;@&lt;hostname&gt;:&lt;path&gt; <\/code><\/p>\n<p><code>scp -i&lt;private key&gt; -P&lt;port&gt; $1.tar.xz &lt;user&gt;@&lt;hostname&gt;:&lt;path&gt; <\/code><\/p>\n<p>copy this code to a file zipnmove.sh and make it executable with the command<\/p>\n<p><code>chmod +x zipnmove.sh<\/code><\/p>\n<p>and then run the command<\/p>\n<p><code>zipnmove.sh foldername`date +%d%m%Y` foldername<\/code><\/p>\n<p>remove the date part if you don&#8217;t want the current date to be part of the filename.<\/p>\n<p>few things to be taken care before you run this command public key of the local system must be already added to remote system.<\/p>\n<p>2. find out public key from private key<br \/>\n<code>ssh-keygen -y -f ~\/.ssh\/&lt;private key&gt;<br \/>\n<\/code><\/p>\n<p>3. Another method is using rsync<\/p>\n<p>Before using this command make sure public key is already added to remote system.<\/p>\n<p><code>rsync -av --progress --rsh=\"ssh -i &lt;private key&gt; -p &lt;port&gt;\" &lt;file or directory to push&gt; &lt;remote system&gt;<br \/>\n<\/code><\/p>\n<p>drop &#8211;rsh if the keys have default names and are in default location same with port. using &#8216;z&#8217; in rsync will compress the data while sending, us it if needed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was working on a project that involves moving data from one point to other, it involves a verity of commands. I am listing some useful tricks. 1. This script is a tiny script to compress, generate md5 and transfer any directory. tar cvJf $1.tar.xz $2; md5sum $1.tar.xz &gt; $1.md5sum scp -i&lt;private key&gt; -P&lt;port&gt; $1.md5sum\u00a0&lt;user&gt;@&lt;hostname&gt;:&lt;path&gt;\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.bhuvankrishna.in\/blog\/2015\/05\/10\/quick-tricks-on-shell\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-140","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/posts\/140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/comments?post=140"}],"version-history":[{"count":1,"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/posts\/140\/revisions"}],"predecessor-version":[{"id":559,"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/posts\/140\/revisions\/559"}],"wp:attachment":[{"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/media?parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/categories?post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/tags?post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}