Count line Length


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Count line Length
# 1  
Old 11-04-2009
Count line Length

I am trying to write a shell scrip that can give me the line length of a record that was in EBDIC and then converted to ASCII. Everything I try reports 1 yet the length is 2000+. I have tried

echo "Line length : ${#FILE}"
echo "FILE" |awk -F, '{print NF}'
awk '{lenth(file)}'

All I can tell is that there is a charcter or something that says end of line even i it is not end of line.

Can anyone give me another way to count every character in a line until the line break?
# 2  
Old 11-04-2009

Is there a null string (\000) in the line?
# 3  
Old 11-04-2009
No there is a ^k\204 at the start
# 4  
Old 11-04-2009

How do you read the line into the variable?

What is the output when you pipe it through hexdump or od -c?
# 5  
Old 11-04-2009
I am jut typing the code in on the command line so it is read in at FILE listed above

od -c gives me:

\v 204 \0

for the fist set of characters.
# 6  
Old 11-04-2009
Quote:
Originally Posted by wbshrk
I am jut typing the code in on the command line so it is read in at FILE listed above

HOW is it read into the FILE variable?

What code do you use?

Quote:

od -c gives me:

\v 204 \0

for the fist set of characters.

\0 is a NUL and ends the string.
# 7  
Old 11-04-2009
Ok if \0 is null how do I get around that? These are all over the record and need to be counted.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to count the length of fasta sequences?

I could calculate the length of entire fasta sequences by following command, awk '/^>/{if (l!="") print l; print; l=0; next}{l+=length($0)}END{print l}' unique.fasta But, I need to calculate the length of a particular fasta sequence specified/listed in another txt file. The results to to be... (14 Replies)
Discussion started by: dineshkumarsrk
14 Replies

2. Shell Programming and Scripting

Count the pipes "|" in line and delete line if count greter then number.

Hello, I have been working on Awk/sed one liner which counts the number of occurrences of '|' in pipe separated lines of file and delete the line from files if count exceeds "17". i.e need to get records having exact 17 pipe separated fields(no more or less) currently i have below : awk... (1 Reply)
Discussion started by: ketanraut
1 Replies

3. Shell Programming and Scripting

Compare file1 header count with file2 line count

What I'm trying to accomplish. I receive a Header and Detail file for daily processing. The detail file comes first which holds data, the header is a receipt of the detail file and has the detail files record count. Before processing the detail file I would like to put a wrapper around another... (4 Replies)
Discussion started by: pone2332
4 Replies

4. UNIX for Dummies Questions & Answers

Count on grep for more than two values in a row of fixed length file

I want to get count on number of records in a few folders by running grep command for more than two columns in a row of fixed length file. suppose if i have a fixed length file has 5 columns and I want to see the record counts for country =can and province = bc and time stamp <= 12 feb 2013... (14 Replies)
Discussion started by: princetd001
14 Replies

5. Shell Programming and Scripting

Check for length which exceeds specified length in a line

Hi, I have a issue, I need to loop through a comma delimited file and check for the length which exceeds specified length , if Yes truncate the string. But my problem is , I do not have to check for all the fields and the field lenght is not same for all the fields. For ex: Say my line... (9 Replies)
Discussion started by: rashmisb
9 Replies

6. Shell Programming and Scripting

awk length count

Morning, every one. I have a file like this: AAEQGAGNQPQH 27 AAGETQY 51 AAGGSSYNEQF 12 AAGGYEQY 72 AAGLEAKNIQY 159 AAGPYEQY 26 AAGQDYNSPLH 45 AAGQGGEQF 1587 AAGREGGNTEAF 4 AAGSPQH 3 AAGSYEQY 45 AAGTGAYEQY 19 AAGTSGNNEQF 79 AAGWNTEAF 37 I want to count the string length of the... (2 Replies)
Discussion started by: xshang
2 Replies

7. Shell Programming and Scripting

how to count string length?

Hi, Gurus, I have a requirement which need count string length. eg. abc bcde defge want to get following: abc 3 bcde 4 defge 5 :wall: thanks in advance! (6 Replies)
Discussion started by: ken002
6 Replies

8. Shell Programming and Scripting

Shell script to count number of ~ from each line and compare with next line

Hi, I have created one shell script in which it will count number of "~" tilda charactors from each line of the file.But the problem is that i need to count each line count individually, that means. if line one contains 14 "~"s and line two contains 15 "~"s then it should give an error msg.each... (3 Replies)
Discussion started by: Ganesh Khandare
3 Replies

9. Shell Programming and Scripting

Deleting Characters at specific position in a line if the line is certain length

I've got a file that would have lines similar to: 12345678 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 23456781 x.00 xx.00 xx.00 xx.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 34567812 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 45678123 x.00 xx.00 xx.00 xx.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 xx.00... (10 Replies)
Discussion started by: Cailet
10 Replies

10. UNIX for Dummies Questions & Answers

How to count the string length

Please can anyone tell me, how to count the string length (2 Replies)
Discussion started by: Anshu
2 Replies
Login or Register to Ask a Question