cut command is really useful when it comes to table data handling.
For example, I have a comma-separated values file:
And for generating a special table containing only names and ages, I can execute this:
cut -d',' -f 1,3 < test.txt. Expectedly here comes the result:
In most cases, you need to specify 3 options to properly manipulate the efficient
We can use
-d option to specify delimiter other than tab the default one. And the delimiter may be specified only when operating on fields(
cut can operate on fields, characters or bytes respectively with
Following the LIST option is the range, where you can specify a point (
-c 3) or a consecutive range (
-c 1-10) and you can combine those together with commas (
-cmight be replaced with
-bfor corresponding purpose.
By the way, bare it in mind that it is one-based numbering system the
cut command is working with other than zero-based one.
There is a option
--complement, which indicates complement of currently specified range as range.
For more examples, please refer to web page — Reference