How to select non-contiguous fields?

To select non-contiguous fields using the cut command, you can specify the fields you want to extract with the -f option, separating the field numbers with commas. You also need to use the -d option to define the delimiter that separates the fields in your input data.

Here’s an example command to extract the first and third fields from a comma-separated file:

cut -d ',' -f 1,3 filename.csv

In this command:

  • -d ',' specifies that the delimiter is a comma.
  • -f 1,3 indicates that you want to extract the first and third fields.

The output will display only the specified non-contiguous fields while maintaining the original delimiter between them.

0 Comments

no data
Be the first to share your comment!