I need some help regarding in writing a Korne shell script, in determining the fixed length records in a data file. We have already utility in place, which does this work. The Code for this is as below. In the below $1 is the parameter passed to the script, which is the data file name.
This script is working for the files which is having characters less than or equal to 10239.
All versions of awk can handle files of any size (subject to memory limitations if you are storing large portions of the file in memory).
With some versions of awk, you could have a problem with long lines. Is that the problem? If so, use GNU awk (gawk).
Quote:
But this script fails for the lengthy data files, where the characters in the file exceeds 10239.
I have got 3 files, which have characters exceeding 13,000 and less than 16,000.
Can anyone let me know, as how to overcome this problem.
======================================================
CHKLEN=`awk 'NR==1 {print length($0)}' $1`
if [ "$CHKLEN" != "" ]
then
awk "length != $CHKLEN { exit 1 }" $1
if [ $? -ne 0 ]
then
return 1
fi
# Add one for CRLF
let CHKLEN=CHKLEN+1
echo $CHKLEN
else
echo 0
fi
return 0
=======================================================
Is there a command that sets a variable length?
I have a input of a variable length field but my output for that field needs to be set to 32 char.
Is there such a command?
I am on a sun box running ksh
Thanks (2 Replies)
Hi, all.
I need to convert a file tab delimited/variable length file in AIX to a fixed lenght file delimited by spaces. This is the input file:
10200002<tab>US$ COM<tab>16/12/2008<tab>2,3775<tab>2,3783
19300978<tab>EURO<tab>16/12/2008<tab>3,28523<tab>3,28657
And this is the expected... (2 Replies)
I am new to shell scripting and I have to to the following
I have a flat file with storename(lenth 20) , emailaddress(lenth 40), location(15). There is NO delimiters in that file.
Like the following str00001.txt
StoreName emailaddress location... (3 Replies)
I have a number of unix text files containing fixed-length records (normal unix linefeed terminator) where I need to find odd records which are an incorrect length.
The data is not validated and records can contain odd backslash characters and control characters which makes them awkward to process... (2 Replies)
Very, very new to unix scripting and have a unique situation. I have a file of records that contain 3 records types:
(H)eader Records
(D)etail Records
(T)railer Records
The Detail records are 82 bytes in length which is perfect. The Header and Trailer records sometimes are 82 bytes in... (3 Replies)
Hi,
Can anyone help with a effective solution ?
I need to change a variable length text field (between 1 - 18 characters) to a fixed length text of 18 characters with the unused portion, at the end, filled with spaces.
The text field is actually field 10 of a .csv file however I could cut... (7 Replies)
I was trying to use the AIX 6.1 sort command to sort fixed-length data records, sorting by specific columns only. It took some time to figure out how to get it to work, so I wanted to share the solution. The sort man page wasn't much help, because it talks about field delimeters (default space... (1 Reply)
I have a peculiar file with record format like given below. Each line is wrapped to next lines after certain number of characters. I want to concatenate all wrapped lines into 1.
Input:(wrapped after 10 columns)
This is li
ne1
This is li
ne2 and
this line
is too lo
ng
Shortline
... (8 Replies)
Hi Team,
I have an issue to split the file which is having special chracter(German Char) using awk command.
I have a different length records in a file. I am separating the files based on the length using awk command.
The command is working fine if the record is not having any... (7 Replies)