Manipulating text files by using commands
Let's now switch our attention to learning about commands that enable us to manipulate text files β just for output reasons head
, tail
, more
, less
, cat
. Some other commands related to the same concepts are going to be covered in later chapters, such as Chapter 8, Using the Command Line to Find, Extract, and Manipulate Text Content, where we discuss more advanced scenarios with text files, such as merging, cutting, and using regular expressions with grep
and sed
to manipulate text content.
Getting ready
We still need the same virtual machines as with our previous recipes.
How to do itβ¦
Let's start by using head
and tail
command, commands that can be used to show the beginning and end of a text file. For example, let's use the /root/.bashrc
file:
[student@cli1 22:28] head /root/.bashrc # ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package...