> I have a file that appears to be delimited by three spaces between
> fields. I tried using cut to seperate the fields, but cut will only
> take single character delimiters. What I need to do is extract
> columns 2,3, and 8, then sort the columns based on column 2. There's
> also a file header, but I don't want to keep it... Is there a way to
> do this from the bash prompt?
Are there spaces in the fields? If not, you can use awk:
{
read ## Discard header (assuming it's just the first line)
awk '{print $2, $3, $8}'
Quote:} < FILENAME | sort
If the fields contain spaces, you can convert the 3-space
delimiters to tabs with sed, then pipe it to awk:
{
read ## Discard header (assuming it's just the first line)
sed "s/ /\t/g" | awk 'BEGIN {FS = "\t"} {print $2, $3, $8}'
Quote:} < FILENAME | sort
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
==================================================================
Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
<http://www.torfree.net/~chris/books/cfaj/ssr.html>