Reading text files
- These are useful when you want to look at the contents of a file, but not edit it.
- Among the most common of these commands are
cat
, more
, and less
.
-
cat
simply prints out one or several files out.
- Useful for small files, but also for concatenating (which is where it got its name)
-
more
and less
are pagers
- You can feed output to them via the pipe operator
- they have keybindings similar to the editor vi:
/
, ?
, gg
. G
.
Exercises
- Move into the hdi2u_files directory.
- Read the file hsy14768.embl using the commands cat, more and less.
- Don’t forget that tab completion can save you typing effort.
cat hsy14768.embl
more hsy14768.embl
less hsy14768.embl
- Use the spacebar to scroll down
- Press q to quit.
- Use the spacebar to scroll down, b to go up a page, and the up and down arrow keys to move up and down the file line by line.
- Press the / key and search for the letters sequen in the file.
- Press the ? key and search for the letters gene in the file.
- Press the n key to search for other instances of gene in the file.