Shell Script - print selected columns

Posted by teepusink on Stack Overflow See other posts from Stack Overflow or by teepusink
Published on 2010-04-14T20:07:05Z Indexed on 2010/04/14 20:13 UTC
Read the original article Hit count: 238

Filed under:

Hi,

I have a txt file with columns separated by tabs and based on that file, I want to create a new file that only contains information from some of the columns.

This is what I have now
awk '{ print $1, $5 }' filename > newfilename

That works except that when column 5 contains spaces e.g 123 Street, only 123 shows up and the street is considered as another column.

How can I achieve what I'm trying to do?

Thanks,
Tee

© Stack Overflow or respective owner

Related posts about shell-scripting