Yesterday, I did some examples of how you can use the command AWK in the Linux command line. Today, I will just quickly do some testing of the CUT command. It is important to normal letters, as Linux separate capital from non-capital letters. If you want some help, you can always run the cut --help command.
cut examples
The cut command can be used to filter content from a document in different ways. For example, it can easily be used to show only the first content on a line, the first characters, the last characters, and so on.
cut -c 5 actors
This command will show you the fifth character on each line in the actors document.
cut -c 1-5 actors
This will show you the first five characters on each line in the actors document.
cut -b 1-5 actors
This will show you the first five bytes on each line in the actors document. The output is similar to the one when using the -c option-
If you have a list looking like this in actors
Christiano:Ronaldo:40
Lionel:Messi:35
Zlatan:Ibrahimovic:41
If you run the following command, you can see the first name and the age in an output.
cut -d: -f 1,3 actors
If the file looks like this:
Christiano Ronaldo 40
Lionel Messi:35
Zlatan Ibrahimovic 41
cut -d " " -f 1,3 actors
Here we changed the colon which was the separator in the first example with " " which is the sign for a space.
Cool right? Now you have learned a little bit more about the CUT command in Linux as well!