The UNIX and Linux Forums  
Hello and Welcome from 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 Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
What the command to find out the record length of a fixed length file? tranq01 UNIX for Dummies Questions & Answers 9 12-04-2008 04:04 PM
line length Sreejith_VK Shell Programming and Scripting 4 03-10-2008 10:46 AM
Find the length of the longest line panknil Shell Programming and Scripting 1 11-03-2007 05:43 AM
AWK - Line length validation en7smb Shell Programming and Scripting 3 05-09-2007 12:04 PM
grep line length limit hnhegde Shell Programming and Scripting 3 10-02-2006 12:47 PM

Closed Thread
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 08-03-2003
dbessell dbessell is offline
Registered User
  
 

Join Date: Aug 2003
Posts: 1
Unhappy Fixing line length in a file

I have a file containing many lines all with varying lengths. I need each line in the file to be 100 characters in width but I can not find a way of doing this. I want to append to each line spaces to bring the width of the line to 100 but I need a generic way to work out how many spaces I need.

Does anyone have any suggestions?
  #2 (permalink)  
Old 08-04-2003
RTM's Avatar
RTM RTM is offline Forum Advisor  
Hog Hunter
  
 

Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
You can find line length with
% cat myinputfile | awk '{print length($0)}'

You would have to add that to your script or process (if a script, then you can find the length of spaces needed by 100 - output_returned) Check the man page on printf, expr, and awk.
  #3 (permalink)  
Old 08-04-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,119
I think that this should do it...
Code:
#! /usr/bin/ksh
typeset -L100 line
IFS=""
while read line ; do 
         echo "$line"
done
exit 0
Closed Thread

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 03:04 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