Long file record


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Long file record
# 1  
Old 12-29-2015
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

Code:
123456789
123456789
123456789
12

This code shows me the length of each record, but in the last record just gives me long 2 which does not help me to give me long 9 as the registration restro


Code:
while read linea
     do
       largo=${#linea}
       echo "largo es: $largo "

          if [ $largo -ne 9 ]
          then
             echo "Longitud De Registro NOK"
         fi
done <  prueba.txt

# 2  
Old 12-29-2015
Please, try

Code:
while IFS= read linea

This User Gave Thanks to Aia For This Post:
# 3  
Old 12-29-2015
thank you very much work needed to perfect what !!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract timestamp from first record in xml file and it checks if not it will replace first record

I have test.xml <emp><id>101</id><name>AAA</name><date>06/06/14 1811</date></emp> <Join><id>101</id><city>london</city><date>06/06/14 2011</date></join> <Join><id>101</id><city>new york</city><date>06/06/14 1811</date></join> <Join><id>101</id><city>sydney</city><date>06/06/14... (2 Replies)
Discussion started by: vsraju
2 Replies

2. 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

3. Shell Programming and Scripting

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: 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... (3 Replies)
Discussion started by: Devesh5683
3 Replies

4. 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

5. 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

6. UNIX for Dummies Questions & Answers

how to read record by record from a file in unix

Hi guys, i have a big file with the following format.This includes header(H),detail(D) and trailer(T) information in the file.My problem is i have to search for the character "6h" at 14 th and 15 th position in all the records .if it is there i have to write all those records into a... (1 Reply)
Discussion started by: raoscb
1 Replies

7. UNIX for Advanced & Expert Users

Script to search a bad record in a file then put the record in the bad file

I need to write a script that can find a bad record (for example: there is date field colom but value provided in the file for this field is N/A) then script shoud searches this pattern and then insert the whole record into the bad file. Example: File1 Name designation dateOfJoining... (1 Reply)
Discussion started by: shilendrajadon
1 Replies

8. Shell Programming and Scripting

splitting a record and adding a record to a file

Hi, I am new to UNIX scripting and woiuld appreicate your help... Input file contains only one (but long) record: aaaaabbbbbcccccddddd..... Desired file: NEW RECORD #new record (hardcoded) added as first record - its length is irrelevant# aaaaa bbbbb ccccc ddddd ... ... ... (1 Reply)
Discussion started by: rsolap
1 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