{"id":35,"date":"2012-06-07T12:09:10","date_gmt":"2012-06-07T12:09:10","guid":{"rendered":"http:\/\/vickistan.com\/?p=35"},"modified":"2012-06-19T15:14:37","modified_gmt":"2012-06-19T15:14:37","slug":"copying-files-in-linux","status":"publish","type":"post","link":"https:\/\/vickistan.com\/?p=35","title":{"rendered":"Copying Files in Linux bash shell"},"content":{"rendered":"<p>So you want to copy a file in Linux? Easy enough.<\/p>\n<p>cp filename newfilename<\/p>\n<p>But sometimes it isn&#8217;t so easy&#8230; Say the file you want to copy begins with a .<\/p>\n<p>You can&#8217;t see these files unless you add -a to your ls command<\/p>\n<p>ls -la<br \/>\n.bashrc<br \/>\n.bash_profile<\/p>\n<p>Once you can see the file, you can copy it as follows:<br \/>\ncp .bashrc .bashrc2<\/p>\n<p>Not so bad, but if it starts with a hyphen it requires special handling to prevent your shell from thinking you are passing a parameter to the cp command. You&#8217;ll need to precede the filename with a .\/ as follows:<\/p>\n<p>cp .\/&#8211;filename newfilename<\/p>\n<p>Another difficulty with copying files is when someone has either intentionally or unintentionally created a file with a non-viewable ASCII character in the name. Say, for instance, someone has created a file with a name preceded by an ASCII space or the name is only an ASCII space. How do you delete that file? The same way as we copied a file starting with a hythen above.<\/p>\n<p>rm .\/ filename<\/p>\n<p>you can also use rm -i to force you to verify the deletion for extra protection.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So you want to copy a file in Linux? Easy enough. cp filename newfilename But sometimes it isn&#8217;t so easy&#8230; Say the file you want to copy begins with a . You can&#8217;t see these files unless you add -a &hellip; <a href=\"https:\/\/vickistan.com\/?p=35\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-35","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/35","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=35"}],"version-history":[{"count":12,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/35\/revisions"}],"predecessor-version":[{"id":63,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/35\/revisions\/63"}],"wp:attachment":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}