Pages: [1]   Go Down
  Print  
Author Topic: Master the command line: Deleting files and folders  (Read 365 times)
HCK
Global Moderator
Hero Member
*****
Posts: 79425



« on: January 07, 2014, 02:00:17 pm »

Master the command line: Deleting files and folders

<article>
   <section class="page">
<p>
When it comes to quickly taking care of daily tasks, the command line can be both powerful and dangerous. Take today’s commands as an example: the <code>rm</code> command allows you to remove (or delete) files. The <code>rmdir</code> command does the same to directories (also know as folders). But be careful: unlike when you move files to the Trash from the Finder, there’s no way to get them back if you use these commands. Still, if you want to tap into Terminal's powers, this is a command you can't overlook. I’ll show you how to add a safeguard to ensure that you only delete files you really want to delete.
</p>
<h2>Why bother deleting files with the command line?</h2>
<p>
Deleting files with the Finder isn't too difficult, plus you can always fish files out of the Trash if you change your mind. So why bother using the command line? Here are some reasons:
</p>
<ul>
<li>You can delete multiple files quickly and efficiently using wildcards.</li>
<li>You can remove files from the Trash when you encounter stubborn errors.</li>
<li>You can delete files that are hidden in the Finder; these files, which can contain settings for certain apps or parts of OS X, contain a dot (.) before their names and the Finder doesn’t show them.</li>
<li>If you've lost access to the Finder because your Mac is on the blink, you might be able to use the command line to troubleshoot the problem.</li>
</ul>
<h2>Delete files</h2>
<p>
It’s dangerously easy to delete files with the <code>rm</code> command. Here's an example. After you launch Terminal (in your /Applications/Utilities folder) type <code>cd ~/Desktop</code> to navigate to the Desktop directory. If you had a file here named MyFile.rtf that you never, ever wanted to see again, you could run this command:
</p>
<p>
<code>rm MyFile.rtf</code>
</p><p class="jumpTag"><a href="/article/2082021/master-the-command-line-deleting-files-and-folders.html#jump">To read this article in full or to leave a comment, please click here[/url]</p></section></article>

Source: Master the command line: Deleting files and folders
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: