Record too long error while running awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Record too long error while running awk
# 1  
Old 03-30-2012
Record too long error while running awk

I have written below script to add substring in a file containing fixed length record, but when I run below script I get error as:
Code:
ERROR:
awk: record `22503004502488344040...' too long

My fixed length record has length around 2000, each file is having 5000 records and total number of files is approx. 4000. Please help me avoid this error as I'm getting this error while I run the script for a single file.

Code:
awk 'BEGIN {sum_a=0;sum_b=0;}
{
  a=substr($0,380,12);
  b=substr($0,392,12);
  sum_a = sum_a+a;
  sum_b = sum_b+b;
}
END {printf"SUM_A=%d\t\tSUM_B=%d\n",sum_a,sum_b}' File_name


Last edited by Scott; 03-30-2012 at 12:13 PM.. Reason: Code tags
# 2  
Old 03-30-2012
What's your OS?
# 3  
Old 03-30-2012
-bash-3.2# uname -a
Linux cmd3n1 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
# 4  
Old 03-30-2012
Is this a unix format text file? i.e.Is each record terminated with a line-feed character?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Long file record

riends I have the following problem: test.txt I have a file that has the following contents: is a fixed-length file to the end of the number 12 has spaces, so that it is fixed length 123456789 123456789 123456789 12 This code shows me the length of each record, but in... (2 Replies)
Discussion started by: tricampeon81
2 Replies

2. Shell Programming and Scripting

How to compare current record,with next and previous record in awk without using array?

Hi! all can any one tell me how to compare current record of column with next and previous record in awk without using array my case is like this input.txt 0 32 1 26 2 27 3 34 4 26 5 25 6 24 9 23 0 32 1 28 2 15 3 26 4 24 (7 Replies)
Discussion started by: Dona Clara
7 Replies

3. UNIX for Dummies Questions & Answers

awk: record too long

Hi All , I am getting record too long for the below command . nawk -F\" '{a=a" "$2} END{for(i in a) print i,a }' test|sort|awk '{for(i=1;i<=NF;i++) t=t"\t"$i;if(NF>max)max=NF} END{for(i=1;i<=max;i++)print t }' File test has 850 records ... Please help.. (2 Replies)
Discussion started by: saj
2 Replies

4. UNIX for Dummies Questions & Answers

Long running sessions

Hi, How can i find out the average cpu utilization of a particular long-running process in UNIX? is there some command for this Thanks (3 Replies)
Discussion started by: arunmanas
3 Replies

5. Shell Programming and Scripting

Monitor a long running process

Gurus, I am writing a shell script that will be used to automate cold backup of an Oracle Database. The database size is around 300G and will take around 5-6 hours to copy. I have finished the script till the copy of the datafiles. Now, I am stuck at the point where I need to monitor the... (4 Replies)
Discussion started by: sunpraveen
4 Replies

6. Shell Programming and Scripting

Script for long running processes....

I searched the forums but didn't see anything related to what I'm looking for. I need a script that would give me a listing of jobs running longer than, for example, 12 hours or so. Thanks in advance for your assistance!! (2 Replies)
Discussion started by: CyberOptiq
2 Replies

7. Shell Programming and Scripting

Determine differient IP in a very long record.

Hi Everyone, I have a txt file with 40k lines. 111 1.1.1.1 111 1.1.1.1 111 2.2.2.2 111 1.1.1.1 111 1.1.1.1 How would use perl to easy have IP list, the final result will be: 1.1.1.1,2.2.2.2, I can only think using if to determine one by one through all 40k, this is working, but... (10 Replies)
Discussion started by: jimmy_y
10 Replies

8. Shell Programming and Scripting

Split long record into csv file

Hi I receive a mainframe file which has very long records (1100 chars) with no field delimiters. I need to parse each record and output a comma delimited (csv) file. The record layout is fixed. If there weren't so many fields and records I would read the file into Excel, as a "fixed width"... (10 Replies)
Discussion started by: wvdeijk
10 Replies

9. Shell Programming and Scripting

Record Length too long -- AWK Problem

Hi All, I have a txt file which is an export of a query result from the database. The txt file contains 'Processid#sqlquery' from the database table.As the sqlquery is too long.... i am unable to get the fields seperated using the awk script as below:- cat sql.txt | awk -F'#' '{printf $2}'... (2 Replies)
Discussion started by: venkatajay_18
2 Replies

10. UNIX for Dummies Questions & Answers

Record too long for awk

I am trying to generate a small report with the help of awk. The contents are present in a file whose last line is very long. I can't shorten this line as its generated after a lot of processing. On reading this file awk says record "starting of line ..." too long record number 30 Now... (2 Replies)
Discussion started by: vibhor_agarwali
2 Replies
Login or Register to Ask a Question