fields with spaces

What's the best command and line options to use if I'm working with a text file that has spaces pretty much inside each description, field? They are not all uniform in each column and I need to extract them. I've already got rid of the tabs with the tr command so its a lot more cleaner now, but I'm just stuck on getting UNIX to recognize where one field ends and another one begins because of the different spaces in each one.

> I've already got rid of the tabs with the tr command so its a lot more cleaner now,
And destroyed any sense of where all the columns are with it no doubt.

If the result is variable width fields, with variable content, which now overlap, then you're stuck.

Fred Flintstone 37 Wilma Pebbles
Barney Rubble 39 Betty Bam Bam

If you'd expanded the tabs with 'expand', and not gotten rid of them with 'tr', then maybe you would have multiple spaces between columns, and some sense of still having a table.

Fred Flintstone 37 Wilma Pebbles
Barney Rubble 39 Betty Bam Bam

At least then various utilities can count characters to establish where the fields are.

If you've still got tabs, then extracting individual fields is dead easy.
Eg. awk -F'\t' '{ print $1,$4 }' and save the removal of them until it's absolutely necessary for display purposes say. Even then, you don't mess about with your original data to do it.

I'm in agreement with Salem, run that file through a quick awk statement to parse it into field based on the tabs and see what you get. It might be the answer you're looking for.

If you have space and/or tabs randomly in between each item on the line, despite the content and its relevancy to other fields, you might want to split on the words like "WEIGHT," etc, split on those and then replace them in your awk/sed statement.