Using the Linux cut command to grab portions of lines from files

One surprisingly easy command for grabbing a portion of every line in a text file on a Linux system is cut. It works something like awk in that it allows you to select only what you want to see from files, enabling you to pull fields (regardless of the delimiter used), characters or bytes. To check on cut, you can ask about its version like this:

$ cut –version
cut (GNU coreutils) 8.32
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David M. Ihnat, David MacKenzie, and Jim Meyering.

Selecting by field

To illustrate how the cut command works, we’ll first run commands using a sample “cities” file that contains details of the largest cities in the US in a tab-separated format. The lines in this file look something like what is shown below:

To read this article in full, please click here

Source:: Network World – Data Center