Click here to view code image
matthew@seymour:~$ cp /home/matthew/documents/oldfilename
/home/matthew/archive/newfilename
Or from anywhere using a path shortcut, you could use this:
Click here to view code image
matthew@seymour:~$ cp ~/documents/oldfilename ~/archive/newfilename
Displaying the Contents of a File with cat
To view the contents of a text file named filename on your screen,
assuming that you are the user matthew, use this command:
Click here to view code image
matthew@seymour:~$ cat filename
Notice that the text is displayed on your screen but that you cannot edit or
work with the text in any way. This command is convenient when you want to
know the contents of a file but don’t need to make any changes. Text editors
for the terminal are covered in Chapter 12, “Command-Line Master Class,
Part 2.” This command works best with short files because the contents of
longer files scroll off the screen too quickly to be read.
Displaying the Contents of a File with less
When you need to view the contents of a longer text file from the command
line, you can use less. This produces a paged output, meaning that output
stops each time your screen is full. You can then use your up- and down-
arrow keys and page-up and page-down keys to scroll through the contents of
the file. Then, use q to quit and return to the command line:
Click here to view code image
matthew@seymour:~$ less filename
In the early days of UNIX, a program called more gave paged output. It was
the first paged output program but did not include the ability to scroll up and
down. less was written to add that capability and was named as a bit of
hacker humor because “less is more.” You can also use more, but today it
is merely an alias for less.