Today, we’ll learn how to manipulate files using four fairly simple commands. So let’s begin!
Before we start with the commands themselves, let’s take a quick stop at a section called…
### …wildcards: ###
Copying, pasting files, creating directories etc. is probably easier using graphical tools, but, if you’d like to perform more complicated tasks, like copying only .html files from one folder to another, and only copying files that don’t exist in the destination directory, CLI just might come in handy. So, to get back to wildcards, it’s basically a shell feature, a set of special characters, that helps you pick out a set of files based on some simple rules (which characters appear in a file name, how many characters, upper/lower case characters etc.). Here’s the table (click to enlarge):
If you use a command with an argument containing a filename, you can use wildcards with no problem.
### cp ###
cp is used to copy files or directories. You can use it pretty easily: navigate to the folder you’d like to copy the files from and to, and simply do
`cp file1 file2`– to copy single files,
or
`cp file1 file2 … directory`– to copy files from your current working directory to the directory specified. Here’s mr Shotts’ table with numerous options: