problem with awk command in script.

#!/bin/sh
date=`date +%y%m%d -d"1 day ago"`
inbound_dir=/vis/logfiles/to_solmis
            cp `grep -il ST~856~ $inbound_dir/*$date*` /vis/sumit/in_ASN/
            echo 'SENDER,RECEIVER,DATE,TIME,ASNUMBER' > a.csv
            for i in /vis/sumit/in_ASN/*
            do
                 mkdir -p /vis/sumit/inboundasns.$date
                 cp `echo $i` /vis/sumit/inboundasns.$date 
                 tr -c '[A-Z] [0-9] [a-z] ~' '[ *]' <$i > b
                 awk -F "DTM~" '{print $1}' b > c
                 awk -F "~SH~" '{print $2}' c > d
                 awk -F "~" '{print $1","$2","$3","$4","$11}' d >> a.csv
            done

Please suggest how to read or print a file which is of 3000 bytes using awk command..
Error is awk cannot read a file whose length is greater than 3000.
Any alternative ????

Are you sure?
try:

cat very_long_file.txt
awk very_long_file.txt

any errors, print it
What's your OS? What's version?

I believe he means lines, not files. Many versions do have an arbitrary limit on the length of lines.

If it's available on your system, try nawk instead of awk. That should be GNU awk, which doesn't have a limit that I'm aware of.

Older awk's more than likely have such a limit. awk on Solaris, for example has a limit of 2.5K-1 byte line length.

Newer awk's most likely don't have such limitations.

This is the difference.
There is no limit of file size.
There's a limit of record lenght.
Use nawk, gawk.
GNU awk is gawk. It's for many distributions.

Hi all,

Thanks for your reply.

I entered nawk instead of awk but didnt work.
error is: nawk not found.
My OS HP-UX.
my script is not able read the file and pick up the required fields when the total size of record was greater than 3000 bytes.

Error looks like:
awk: Input line ISA~00~ ~00 cannot be longer than 3,000 bytes.
The source line number is 1.

How to overcome this error??

Is this a joke?
This is very funny.

tr -c '[A-Z] [0-9] [a-z] ~' '[ *]' <$i > b

you translate all characters A..Z, 0..9, a..z, ~ to ' ',
now you set FS-field separator to 'DTM~' (no any characters D, T, M, ~) what for

awk -F "DTM~" '{print $1}' b > c

.......

actually sample of data look like:

ISA~00~          ~00~          ~ZZ~ABCDE          ~ZZ~AAAAA          ~100902~0647~U~00200~000003479~0~P~>
GS~SH~ABCDE~0185A~100902~0647~2173~X~002002XXX
ST~856~0001BSN~00~00902064701~100902~0647
DTM~011~100902~1014

Every file contain such type of data varying in record length.
I need to read all records & pick up fields from the record that are in red and store it .csv file.

For this I wrote a script.
I am beginner,I dont know how to use FS in awk command.

Advise me sir...

Try gawk instead, then.

And if you don't have either, install one.