{"id":96,"date":"2009-09-08T13:18:46","date_gmt":"2009-09-08T13:18:46","guid":{"rendered":"http:\/\/www.adriangrigoras.com\/blog\/?p=96"},"modified":"2009-09-08T13:18:46","modified_gmt":"2009-09-08T13:18:46","slug":"copy-a-file-which-is-generated-every-day","status":"publish","type":"post","link":"https:\/\/adriangrigoras.com\/blog\/copy-a-file-which-is-generated-every-day\/","title":{"rendered":"Copy a file which is generated every day"},"content":{"rendered":"<p>When you want to copy a file which is generated every day and has a date inserted inside its name, you can use the following bash file:<\/p>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">#!\/bin\/bash<\/div>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">dt=`date +%Y%m%d`<\/div>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">#dt=`date +%Y%m%d%H%M%S`<\/div>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">from_dir=&#8221;\/home\/adrian\/1&#8243;<\/div>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">to_dir=&#8221;\/home\/adrian\/2&#8243;<\/div>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">from_file=&#8221;$from_dir\/myfile&#8221;_&#8221;$dt&#8221;.csv<\/div>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">to_file=&#8221;$to_dir\/myfinalfile.csv&#8221;;<\/div>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">#echo &#8220;cp $from_file $to_file&#8221;<\/div>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">cp $from_file $to_file<\/div>\n<blockquote>\n<address>\n<address>#!\/bin\/bash<\/address>\n<address><\/address>\n<address>dt=`date +%Y%m%d`<\/address>\n<address>#dt=`date +%Y%m%d%H%M%S`<\/address>\n<address><\/address>\n<address>from_dir=&#8221;\/home\/adrian\/1&#8243;<\/address>\n<address>to_dir=&#8221;\/home\/adrian\/2&#8243;<\/address>\n<address><\/address>\n<address>from_file=&#8221;$from_dir\/myfile&#8221;_&#8221;$dt&#8221;.csv<\/address>\n<address>to_file=&#8221;$to_dir\/myfinalfile.csv&#8221;;<\/address>\n<address><\/address>\n<address>#echo &#8220;cp $from_file $to_file&#8221;<\/address>\n<address>cp $from_file $to_file<\/address>\n<div><\/div>\n<\/address>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>When you want to copy a file which is generated every day and has a date inserted inside its name, you can use the following bash file: #!\/bin\/bash dt=`date +%Y%m%d` #dt=`date +%Y%m%d%H%M%S` from_dir=&#8221;\/home\/adrian\/1&#8243; to_dir=&#8221;\/home\/adrian\/2&#8243; from_file=&#8221;$from_dir\/myfile&#8221;_&#8221;$dt&#8221;.csv to_file=&#8221;$to_dir\/myfinalfile.csv&#8221;; #echo &#8220;cp $from_file $to_file&#8221; cp $from_file $to_file #!\/bin\/bash dt=`date +%Y%m%d` #dt=`date +%Y%m%d%H%M%S` from_dir=&#8221;\/home\/adrian\/1&#8243; to_dir=&#8221;\/home\/adrian\/2&#8243; from_file=&#8221;$from_dir\/myfile&#8221;_&#8221;$dt&#8221;.csv to_file=&#8221;$to_dir\/myfinalfile.csv&#8221;; #echo &#8220;cp $from_file\u2026 <span class=\"read-more\"><a href=\"https:\/\/adriangrigoras.com\/blog\/copy-a-file-which-is-generated-every-day\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-96","post","type-post","status-publish","format-standard","hentry","category-bash"],"_links":{"self":[{"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/posts\/96","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/comments?post=96"}],"version-history":[{"count":0,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/posts\/96\/revisions"}],"wp:attachment":[{"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/media?parent=96"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/categories?post=96"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/tags?post=96"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}