Department of Engineering

IT Services

File Manipulation

Create a file in your home directory called flowers with the names of some flowers in it. If you have not got the editor Emacs running you should start it up now to edit the file flowers. When you have typed in the names of the flowers save the file flowers to disk. Use the ls command in the terminal window to examine the files in your current working directory (ls is short for `list files'). You can obtain a more detailed listing using ls -l.

  • Copying Files:- Use the cp command to make a copy of the file flowers. Call your second copy myplants. You should type:
    cp flowers myplants

    Use ls again to see that the new file has appeared

    Leave the flowers file alone but edit myplants and add the names of some plants which are not flowers. When you have finished adding to the myplants file, save it to disk.

  • Moving Files:- The name myplants is rather long so let's rename this file. Use the command:
    mv myplants plants

    to rename the file plants. If you already have a file of that name, mv will prompt for confirmation. The mnemonic mv is short for `move.' Do an ls again to see what you have done.

  • Viewing and printing Files:-

    To look at the contents of files without editing them you use the command more. Try

    more flowers

    The command to print out a copy of one of your files on the line printer is lp. For example, lp flowers would print out the file flowers. Please don't do this now or there will be rather a lot of wasted paper.