back contents next index

UNIX Commands for Manipulating Files

***Files are used to store information, for example, data or the results of some analysis.

***Files on the Alpha are equivalent to files or documents on other computers. However, you have the advantage of automatic backups every night and access to your files from any internet connected computer.

***Many GCG programs offer you a default name for the output file
***If you use the same program many times, you will overwrite the output file each time - deleting your previous results file.

***Choose a new, more specific name when GCG prompts you for the name of the output file.


***Now, let's deal with commands to copy and delete files.

***Remember that UNIX is case sensitive and that you can substitute a * as a wildcard for any filename or extension.

***cp is both simple and powerful - it lets you copy a file from anywhere to anywhere and name the new file whatever you want.

  • In its simplest form, cp makes a copy of a file in your current directory.
    cp filename.ext  newfilename.ext
  • to copy a file into a subdirectory:
    cp filename.ext   subdir/newfilename.ext
  • to copy a file from another directory into your current directory:
    cp /dirname/filename.ext  newfilename.ext

*** mv allows you to move files to other directories, but it is also used to rename files. Filename and directory syntax for mv is exactly the same as for the cp command.
mv filename.ext   subdir/newfilename.ext


*** NOTE: When you use mv to move a file into another directory, the current file is deleted.
*** rm is the command to delete files.

rm filename.ext


*** OK, that covers the simple stuff about moving files around. Now for some commands that let you work with the contents of files. Most files on a UNIX machine will be plain old text files. You will want to look at their contents on the screen, add one to another, and check for differences.

***cat types the contents of a file to the screen.

  • For long files, this can be annoying since the text will scroll past much too quickly to read; you can use the more command to scroll through a text file one screenfull at a time.
    more testfile.txt 
***diff compares two text files and lists all of the differences.


back contents next index

Using Computers for Molecular Biology
Stuart M. Brown, Ph.D, RCR, NYU Medical Center
Comments to: browns02@mcrcr.med.nyu.edu