How to trim a 419th column in UNIX file.

Hi All,

I have a UNIX file, which has Total of 532 column, each delimited with ^~^. One of the column (419) is 202 character long. In real case, it should be 22 character long.

cut -d~ -f419 filename

^404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040402D2D404D4450444040604048E040404240C0404040
42404040404040584042544040404044404040404040404040404040404040^

I need to trim it to 22 character. at the begining & end ^ sould come. I have searched & found following link.

But when i execute the command given here, AWK is not supporting it.

Can some one help me?

What does "not supporting it" mean? What does happen? What did you expect to happen? What did you want to happen?

What is the exact script you are running?

It gives following error.

$ awk 'NR==1{print;next}{$419=substr($419,180)}1' ABC20090112.OUT > aaa
awk: trying to access field 419

all record(columns) are delimited with ^~^ & there are 532 columns.

From my data file i want to trim 419th column from 202 characters to 22 characters , so that i can load it.

You must tell awk that your fields (not records) are tilde delimited:

awk -F~ 'NR == 1 { .... } ....' ....

It gives same error.

$ awk -F~ 'NR==1{print;next}{$419=substr($419,180)}1' ABC20090112.OUT > aaa
awk: trying to access field 419

or

$ awk -F^~^ 'NR==1{print;next}{$419=substr($419,180)}1' ABC20090112.OUT > aaa
awk: trying to access field 419