Hdi2u S17

From wiki
Revision as of 22:35, 19 April 2017 by Rf (talk | contribs) (Created page with "= Copying files and directories = * The basic command used to copy files using the command line is <code>cp</code>. * At a minimum, you must specify two arguments: the name o...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Copying files and directories

  • The basic command used to copy files using the command line is cp.
  • At a minimum, you must specify two arguments: the name of the file to be copied, and where you wish to copy the file to.
  • The main things to know about using the cp command are:
  • if you provide the name of an existing directory as the second argument, the file named in the first argument will be copied into that directory.
  • otherwise, it will be assumed that the second argument is another name for the first file, a clone so to speak.
  • if you provide more than two arguments to cp, the final argument needs to be the name of a directory
  • This command it not harmless, if you choose a new name that happens to already be a file, that file will be overwritten.

Exercises

cp unknown.fasta my_new_file.fasta - clones unknown.fasta with the new name my_new_file.fasta
cp unknown.fasta my_new_directory - probably not what you wanted! It just makes another file. ==
mkdir an_actual_directory
cp unknown.fasta an_actual_directory - copy unknown.fasta into an_actual_directory you just made
cp *.embl an_actual_directory - copy all the .embl files into the new directory in one go
  • To copy whole directories, with all the subfiles and subdirectories, use the –R option, (meaning recursive).
cp –R an_actual_directory foo
cp –R ../blastdb .