Line Wrapping using Sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Line Wrapping using Sed
# 1  
Old 05-24-2011
Line Wrapping using Sed

Hi,

I want to wrap the lines if a line starts with number. I tried the following sed command, but I do not get the required output. It is replacing the first number.

Can some one please help me on this?

Command I used
Code:
sed -e :a -e '$!N;s/\n[0-9]//;ta'  -e 'P;D' testfile

I/P file:
Code:
Test_sed,
05/20/2010,15:06,05/20/2010,15:06,SU,91107794/1,

O/P I got:
Code:
Test_sed,5/20/2010,15:06,05/20/2010,15:06,SU,91107794/1,

Expected output
Code:
Test_sed,05/20/2010,15:06,05/20/2010,15:06,SU,91107794/1,


Last edited by Franklin52; 05-24-2011 at 12:46 PM.. Reason: Please use code tags
# 2  
Old 05-24-2011
Hi,

not tested but you could try
Code:
sed -e :a -e  '$!N;s/\n\([0-9]\)/\1/;ta'  -e 'P;D' testfile

# 3  
Old 05-24-2011
Hi Chirel,

Thats fantastic Smilie. It works. Much thanks to you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed command to replace a line at a specific line number with some other line

my requirement is, consider a file output cat output blah sdjfhjkd jsdfhjksdh sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf hellow there this doesnt look good et cetc etc etcetera i want to replace a line of line number 4 ("this doesnt look good") with some other line ... (3 Replies)
Discussion started by: vivek d r
3 Replies

2. Shell Programming and Scripting

UNIX mail and wrapping

Greetings, I am by no means a Unix expert and hope that someone here can help me out. I am sending an email from within a Progress character program. This works fine. My issue is that I would like to send more than 80 characters and the email is wrapping at 80 chars. Is this an email... (9 Replies)
Discussion started by: Nosredna
9 Replies

3. Shell Programming and Scripting

SELECT and wrapping to next column

Hi all, Am trying to write a menu driven script using SELECT and if I have more than 4 options, it wraps to the next column. That is if I have 6 choices, items 5 and 6 are in the second column. Is there any settings that control this behavior or is it due to some stty settings? stty -a... (3 Replies)
Discussion started by: newbie_01
3 Replies

4. Shell Programming and Scripting

wrapping text not exceeding 80 characters

I have a file where the text might exceed 80 characters. I want to have the maximum text lengths to be 80, and cut text from a space. I written an awk script below but does not seem to work very well { gsub("\t"," ") $0 = line $0 while (length <= WIDTH) { line = $0 ... (3 Replies)
Discussion started by: kristinu
3 Replies

5. UNIX for Dummies Questions & Answers

Putty and wrapping on SunOS 5.9

I am very frustrated with this. I've added the following into my .profile and .bashrc: #this one makes sure that long commands strings line wrap to the next line && return #instead of wrapping onto the start of the same line. shopt -s checkwinsize However, it just never works for me.... (7 Replies)
Discussion started by: mrwatkin
7 Replies

6. UNIX for Dummies Questions & Answers

bash history and command line wrapping

By default, we use ksh (88) as our shell. I prefer bash, so I added this line to my .profile: exec bash -o viI also added this to my .bashrc?: #*********************************************** #These are important tweaks specific to BASH: #***********************************************... (1 Reply)
Discussion started by: mrwatkin
1 Replies

7. Shell Programming and Scripting

automatic word wrapping

Hallo, I want to have this Output: Name Street Phone Mail Favorite_thing_o f_what_ever_you_ want Jak street1 0123 jak@test blue egs .com O'Neill street2 4567 ... (1 Reply)
Discussion started by: wiseguy
1 Replies

8. Shell Programming and Scripting

Wrapping ksh script

Hi folks, We want to protect our ksh scripts from our customers.We don't want to let them the option to viewor modify the scripts. Is there a way ro wrap a ksh script? Thanks in advance, Nir (2 Replies)
Discussion started by: nir_s
2 Replies

9. Shell Programming and Scripting

Line wrapping problem when using awk

I am fairly new at this, I wrote a awk program to give me some summary information about a file. At the end of the program I want to print some variables but for some reason it keeps wrapping the last variable on a new line in the output file. Here is the print command print "99", file_id,... (1 Reply)
Discussion started by: placroix1
1 Replies

10. Shell Programming and Scripting

Wrapping a bash script for CGI

I hope its ok to start a new thread, I was going to use my existing one but thought a new one would better clarify things and provide better search for future reference. Well I have my bash program working now, all nice, user input validated, output formatted, everything is looking sexy. Now... (2 Replies)
Discussion started by: andyj
2 Replies
Login or Register to Ask a Question