Looking at file contents with the "more" and "cat" commands
If I want to be sure that I have the right file I can also look at it with the more
command, like this:
more foo.html
This command shows the contents of the file, like the "type" command on DOS, except it provides features to scroll the contents. When I first execute the command it displays the first screenful of information for the file, and then lets me scroll forward and backwards through the file using the [Spacebar] key to go forward one screen, the [b] key to go backward one screen, and the [Enter] key to go forward one line. Most systems are even nicer, and let you use the [UpArrow] and [DownArrow] keys to scroll through the file.
You can do a bunch more things when the more
command is showing a file, like search for stuff, but we'll get to that another time. When you're finished looking at the file with this command just hit the letter [q] to quit, and you'll be returned to the command prompt.
As one last note, if I were more of a crazy person I might use the cat
command instead of the more
command, like this:
cat foo.html
"cat" stands for concatenate, and works much more like the DOS "type" command, displaying all of the file contents as fast as the system can display them. But I prefer the more
command.
(The cat
command is actually more powerful than the DOS "type" command, but I'll have to save that for another time.)
Removing/deleting a file
Oops, I just remembered, while I'm here I meant to delete a file in my home directory aptly named "delete.me". To get back to my home directory I just type the cd
command, with no arguments, like this:
cd
and my prompt changes to this:
foo.bar.com:/home/al> _
With no arguments supplied to it, the cd
command simply returns me to my home directory. I then remove the file like this:
rm delete.me
If you're system is setup to be conservative you might be prompted with something like an "Are you sure?" prompt, but I haven't set up my system that way, and I don't see any output, and I know my file is gone (because I don't see an error).