SED command to add text before a line

March 23, 2011 at 22:04:50
Specs: UNIX SCO Openserver
Hi,

I'm looking for a sed command, which wil place a text before every line that doesn't start with a colon (:) exept for the first 3 lines. Can anybody help me? Thanx in advance.
Kluther


See More: SED command to add text before a line

Report •

#1
March 24, 2011 at 01:40:51

sed  '4,$s/^[^;]/text:/' file



Report •

#2
March 24, 2011 at 03:11:59
Hi Kurumi,

thanx for your reply! It works, but there is 1 import thing that does not work: Only the lines that do not start with : must be altered. Do you have a salution? Thanx

Kluther


Report •

#3
March 24, 2011 at 03:19:45
Hi Kurumi,

I have found the previous problem. But I have a new one: the command replaces the first character of the line. I don't want this to happen. The line must stay intact.

Kluther


Report •

Related Solutions

#4
March 24, 2011 at 04:09:40
the least you could is to provide samples for input file and output you need.

Report •

#5
March 24, 2011 at 04:15:29
Hi Kurumi,

this is the input:

thanx,
Kluther


Report •

#6
March 24, 2011 at 05:39:12

sed '4,${/^[^:]/s/^/:86:/}' file


Report •

#7
March 24, 2011 at 06:02:19
Hi Kurumi,

have tested this? When I try it I get " sed:Command garbled: 4,${/^[^:]/s/^/:86:/}

OH, never mind It works on Ubuntu. I think it is a version problem.


Report •

#8
March 24, 2011 at 23:30:11
Hi Kurumi,

Thank you very much for helping me out. The only thing I had to change on SCO was using gwxsed instead of sed.

Kluther


Report •

Ask Question