Retrieving values from tab-delimited file in unix script

Hi

I am trying to retrieve values from a tab-delimited file.I am using


while read record

value=`echo $record | cut -f12`

done

Where 12 is the column no i want retieve and record is one line of the file.
But it is returning the full record.
Plz help

try to use awk with the file .
ex : awk '{ print $12 }' file_name

Hi

I tried with a test file.It worked perfectly fine.
But for the file that I have to process,it is not working.
This file has been created from an excel file by converting the excel to a tab-delimited windows file.

Any idea why this file is not getting processed? :confused:

Thanks

I believe you need to run it through 'dos2unix'!

-Enjoy
fh : )_~

You need to tell cut that the delimiter is a tab and to put quotes round $record.

#!/bin/ksh
TAB=`echo "\0011\c"`
cat tab_delimited_file | while read record
do
        value=`echo "${record}" | cut -f12 -d"${TAB}"`
        echo "${value}"
done