Asked • 05/05/19

How to make the 'cut' command treat same sequental delimiters as one?

I'm trying to extract a certain (the fourth) field from the column-based, 'space'-adjusted text stream. I'm trying to use the `cut` command in the following manner: `cat text.txt | cut -d " " -f 4` Unfortunately, `cut` doesn't treat several spaces as one delimiter. I could have piped through awk `awk '{ printf $4; }' ` or sed `sed -E "s/[[:space:]]+/ /g"` to collapse the spaces, but I'd like to know if there any way to deal with `cut` and several delimiters natively?

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.