1846167 Members
3289 Online
110254 Solutions
New Discussion

error message with awk

 
ericfjchen
Regular Advisor

error message with awk

#awk 'FS=","{if ($4!=0) print $1,$5,$51,$52,$53,$54}' /tmp/1.txt

-------
Error msg
-------
awk: Input line 99783,0,3,249,ATC_au cannot be longer than 3,000 bytes.
The input line number is 686. The file is /tmp/1.txt.
The source line number is 1.
=====

How to solve the problem

Thanks
3 REPLIES 3
Leif Halvarsson_2
Honored Contributor

Re: error message with awk

Hi,
Is the lines (records) in the file not separated with newlines ? If not, you must also set the RS parameter in the BEGIN statement.
Hein van den Heuvel
Honored Contributor

Re: error message with awk

Well, the message seems very clear.
(What part of "cannot be longer than 3,000 bytes do you not understand? :-)
Is that line 686 longer than 3000 bytes?
And is that length indeed as expected?

Get a better awk? See for example:

http://forums2.itrc.hp.com/service/forums/questionanswer.do?threadId=53114

Use perl?

Untested:

perl -ne '@words=split(/,/); print join(',',@words[0,4,50..53])."\n" if @words[3]' /tmp/1.txt

hth,
Hein.


Muthukumar_5
Honored Contributor

Re: error message with awk

Hein is given answer with perl. Anyway we can try with cut (I hope). ?

while read line;
do
if [[ $(echo $line|cut -d',' -f4) != "" ]]
then
echo "$(echo $line|cut -d',' -f1,5,51-54)"
fi
done < /tmp/1.txt

P.S: Not checked. Pls give example you have tried.

hth
Easy to suggest when don't know about the problem!