Unix Commands (Cont…)

(More on files)

1. cp
Duplicate copies of a file can be made by using the cp (copy) command.
<machine>% cp original.c duplicate.c
This makes a copy of the file original.c as duplicate.c.

<machine>% cp ~/starwars/jabba .
This copies the file jabba in the directory starwars to the current directory. The symbol . stands for the current directory. The symbol ~ stands for the home directory.

2. mv
Renaming a file can be done by using the mv command and moving it from one name to another.
<machine>% mv file.old file.new
The file that was named file.old is now named file.new. Beware that if you move a file to another one that already exists the target file is replaced.

3. more
More is a command used to read text files. For example, we could do this:

<machine>% more poems
The effect of this to let you read the file "poems ". It probably will not fit in one screen, so you need to know how to "turn pages". Here are the basic commands:

q --- quit more
spacebar --- read next page
return key --- read next line
b --- go back one page
For still more information, use the command man more.

4. alias (for csh users)

Remembering the name of a command is a difficult job when it comes to long filenames. We can assign your own name for a command by using an alias.

Assigning an alias is done with the command:
alias name definition

To create a simple alias:

<machine>% alias del='rm -i'
<machine>% del memo.txt
rm: remove memo.txt? y

This creates the alias del for the command rm -i which prompts you for confirmation that you want to remove a file before it does so.

This is a very useful command when trying to run a program in another directory. It will save the pain of typing in the complete path of the filename.