LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-17-2007, 04:15 PM   #1
DoDo1975
LQ Newbie
 
Registered: Nov 2006
Posts: 17

Rep: Reputation: 0
Insert after every nth character using sed


Hi,

I am trying to figure out how to use sed to insert something after n characters.

I have a cgi script that outputs its progress to the browser using periods. I want to put a </br> tag every 100 or so periods to stop browsers from improperly displaying my table.

So how do I use sed to insert something after every 100th period?

Thanks,
 
Old 01-17-2007, 06:41 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Maybe something like this
Code:
sed 's/\./&\<\/br\>/100' file.txt
 
Old 01-17-2007, 06:59 PM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
sed is operating on each line of input, so if you want to use this in a pipeline, waiting until n characters have been written where there are not newlines between the characters, sed is not suitable.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert CRLF's with sed? unSpawn Programming 6 11-22-2006 07:46 AM
How do I insert special character with alt? Meriadoc Linux - Newbie 5 05-17-2006 10:42 AM
Insert a special character with the keyboard? Schreiberling Linux - General 0 03-05-2006 09:09 AM
insert a symbol with sed tonton Programming 5 08-31-2004 11:33 AM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration