Removing Characters from Output with cut
Learn how to remove characters from the output using the cut command.
We'll cover the following...
The cut
command
Now, let’s discuss the cut
command. The cut
command lets us remove text from the output stream or a file. Let’s give it a try:
$ echo 'hello world' | cut -c 2-4
Here’s how it works. The -c
flag tells the cut
command to cut at characters rather than bytes. The value is 2-4
, which tells cut
to cut out everything other than characters 2
through 4
.
We can also specify that we want everything from the beginning of the string until the specified position. For ...