Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The default delimiter in awk is white-space to non-whitespace change.

The default for cut is the tab character.

Can I tell cut to use non-white-space to white space delimters?



foo  bar

cut -d' ' -f2 a

prints just a space, but should print bar.

awk '{ print $2; } a

print bar.

Sure, often you can just use awk as a cut replacement if you need that semantics. But cut has the advantage that it is very memory efficient. Especially it does not load unused columns into memory (unlike some awks).

share|improve this question
up vote 3 down vote accepted

I don't see how to make cut(1) do what you want. I believe you are correct in believing that if you have mixed whitespace delimiters that the best alternative is awk(1).

share|improve this answer

You could preprocess your data with something like tr -s ' ' '\t'. But you wouldn't get any benefit unless your lines were very long. (How long? measure and find out.)

share|improve this answer
yeah, tr is a good work-around. And yes, I have some weird log files with very long lines (several MB). Don't ask. – maxschlepzig Aug 31 '10 at 10:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.