The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Manipulating a fixed length file w/o PERL dabear Shell Programming and Scripting 4 03-31-2008 04:33 PM
use SQL loader to dump a fixed length file in to DB anumkoshy Shell Programming and Scripting 2 10-10-2007 05:53 AM
fl command - set record length Tom Siegel Shell Programming and Scripting 2 07-17-2006 09:50 AM
fixed record length george_ Shell Programming and Scripting 16 03-28-2006 05:41 AM
creating a fixed length output from a variable length input r1500 Shell Programming and Scripting 2 12-03-2003 01:09 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-09-2007
tranq01 tranq01 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 2
What the command to find out the record length of a fixed length file?

I want to find out the record length of a fixed length file? I forgot the command. Any body know?
  #2 (permalink)  
Old 10-09-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,847
Code:
awk '{print length;exit}' filename
in shell (bash, zsh, ksh93):

Code:
<filename IFS= read;echo ${#REPLY}

Last edited by radoulov; 10-09-2007 at 02:36 PM.. Reason: IFS for shell version adjusted
  #3 (permalink)  
Old 10-09-2007
tranq01 tranq01 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 2
Thank you. that worked.
  #4 (permalink)  
Old 10-19-2007
wilmoore wilmoore is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 1
Quote:
Originally Posted by tranq01 View Post
I want to find out the record length of a fixed length file? I forgot the command. Any body know?
You might also try:

Code:
wc -L filename
  #5 (permalink)  
Old 12-04-2008
naughty21 naughty21 is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 16
Hi ,


how can we know the length of a field value if it is like below for xml file

<EmailAddress>abc@gmail.com</EmailAddress>

I need length of abc@gmail.com which is there in between tags

any help in this ...im doing this in korn shell

Last edited by naughty21; 12-04-2008 at 02:01 PM..
  #6 (permalink)  
Old 12-04-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink Here is an approach

Code:
> echo `echo "<EmailAddress>abc@gmail.com</EmailAddress>" | tr ">" "\n" | tr "<" "\n" | grep "@" | wc -c`
14
Note that I am off by one character as the echo gives a new-line.
Thus...

Code:
> echo `echo "<EmailAddress>abc@gmail.com</EmailAddress>" | tr ">" "\n" | tr "<" "\n" | grep "@" | wc -c` -1 | bc
13
or

Code:
> echo "<EmailAddress>abc@gmail.com</EmailAddress>" | tr ">" "\n" | tr "<" "\n" | grep "@" | tr -d "\n" | wc -c
13
  #7 (permalink)  
Old 12-04-2008
naughty21 naughty21 is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 16
Quote:
Originally Posted by joeyg View Post
Code:
> echo `echo "<EmailAddress>abc@gmail.com</EmailAddress>" | tr ">" "\n" | tr "<" "\n" | grep "@" | wc -c`
14
Note that I am off by one character as the echo gives a new-line.
Thus...

Code:
> echo `echo "<EmailAddress>abc@gmail.com</EmailAddress>" | tr ">" "\n" | tr "<" "\n" | grep "@" | wc -c` -1 | bc
13
or

Code:
> echo "<EmailAddress>abc@gmail.com</EmailAddress>" | tr ">" "\n" | tr "<" "\n" | grep "@" | tr -d "\n" | wc -c
13
thanks for your reply

but if we dont know what is there in between tags then how can we do means if we dont know/we didnt see the email id which is in between tags

for ex: EmailAddress>-------</EmailAddress>" in this ---- is nothing but some email id
Sponsored Links
Closed Thread

Bookmarks

Tags
shell script, shell scripting, unix scripting, unix scripting basics

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 10:37 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