The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Deleting Characters at specific position in a line if the line is certain length Cailet Shell Programming and Scripting 10 12-17-2008 02:41 PM
Length of each line. senthil_is Shell Programming and Scripting 7 08-28-2008 09:18 AM
line length Sreejith_VK Shell Programming and Scripting 4 03-10-2008 10:46 AM
AWK - Line length validation en7smb Shell Programming and Scripting 3 05-09-2007 12:04 PM
How to count the string length Anshu UNIX for Dummies Questions & Answers 2 06-15-2006 04:32 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 4 Weeks Ago
wbshrk wbshrk is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 8
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 (permalink)  
Old 4 Weeks Ago
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,380

Is there a null string (\000) in the line?
  #3 (permalink)  
Old 4 Weeks Ago
wbshrk wbshrk is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 8
No there is a ^k\204 at the start
  #4 (permalink)  
Old 4 Weeks Ago
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,380

How do you read the line into the variable?

What is the output when you pipe it through hexdump or od -c?
  #5 (permalink)  
Old 4 Weeks Ago
wbshrk wbshrk is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 8
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 (permalink)  
Old 4 Weeks Ago
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,380
Quote:
Originally Posted by wbshrk View Post
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.
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:03 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0