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 > 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
count, split and thumbnail creation of images prvnrk UNIX for Advanced & Expert Users 1 08-14-2008 02:12 AM
Count specific character(s) very large file dcfargo Shell Programming and Scripting 3 07-01-2008 09:25 AM
How to split a value according to character position michaeltravisuk UNIX for Dummies Questions & Answers 4 05-27-2008 07:07 AM
count character myguess21 Shell Programming and Scripting 13 03-06-2008 03:07 PM
Count occurances of a character in a file Shivdatta Shell Programming and Scripting 6 12-24-2007 04:23 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-22-2008
vikash.rastogi vikash.rastogi is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 3
How to split a text after fix character count

HI,

I want to split a text after certain fix character count in text.

For eg: My file is containing text like:

AURBJR,AURCID,AURVID,CHANDV,DAMNEW,DHMMAN,GANGAN,GARKHE,GOREGA,JEJKHA,JEJSHI,JINTUR,JMKKUS,JUNAWA,KA LKAL,KHOJEW,KUNJIR,MAGARP,MAHAD,

in this i want to print text after each 120 character in the next line.

Pls help.

  #2 (permalink)  
Old 10-22-2008
avis1981 avis1981 is offline
Registered User
  
 

Join Date: Oct 2008
Location: NC
Posts: 21
awk '{ print substr($0,1,120)"\n"substr($0,121)}' <filename> > outfilename
  #3 (permalink)  
Old 10-22-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,419
Quote:
Originally Posted by vikash.rastogi View Post
..print text after each 120 character in the next line.
Code:
sed 's/\(.\{120\}\)/&\
/g' filename

Last edited by danmero; 10-22-2008 at 12:01 PM.. Reason: quote the OP
  #4 (permalink)  
Old 10-22-2008
freelong freelong is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 38
Try this one:
Code:
sed 's/./&\
> /120' filename
  #5 (permalink)  
Old 10-23-2008
vikash.rastogi vikash.rastogi is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 3
It is not working at all, is there any "fold" command in UNIX? i heared abt it but not confirm.
  #6 (permalink)  
Old 10-23-2008
avis1981 avis1981 is offline
Registered User
  
 

Join Date: Oct 2008
Location: NC
Posts: 21
not working at all?
Can you tell what is the expected output and provide what you tried?
Sponsored Links
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 05:58 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