how to use ed ?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to use ed ?
# 1  
Old 09-22-2004
Question how to use ed ?

hi all. the problem:

file contains a string like...

impossible mission

...now, that should be the impossible mission..

that means, I wanna make a string in front of the other strings but in the same line..

with vi it isn't a problem...easy.

but I wanna take the ed...

ed file
i
the
.
w
Q

didn't make it..because the content of the file is

the
impossible mission

but not "the impossible mission" ..just only one line.

so far and thx for any help...
# 2  
Old 09-22-2004
perhaps by awk...the man page is too difficult Smilie

by the way, is there a chance to generate a automatic return/enter...like the system takes the return after a prompt, so that you haven't got to hit the button ?


so far..
# 3  
Old 09-22-2004
Using ed, I think you'd have to do
Code:
ed file
s/impossible/the impossible/g
w
q

Or using sed
Code:
sed 's/impossible/the impossible/g' file > newfile

Cheers
ZB
# 4  
Old 09-22-2004
thx. yes, of course that should work....

furthermore it was an example. my problem is that you shouldn't know the string "impossible"...it's unknown

I just only wanna read an input and write it into a file - no problem to solve..... - but then I wanna get a string in front of the whole string I've read and written in the file...that's the problem. and this should happen automatically. not with the vi.

a chance could be

ed file..then you've three possibilities a i c
a...append, i...insert, c...clear

but when you make i it takes the string above not in front of the string of the written file....


# 5  
Old 09-22-2004
Ummm....so you to insert "the " in front of line one?

sed '1s/^/the /' < inputfile > outputfile
# 6  
Old 09-23-2004
MySQL great!

Smilie thx, it works perfect....

sed -e ´1s/^/frontstring/´<infile >outfile
# 7  
Old 09-24-2004
Error new problem .....

what now if I wanna get the string in front of all lines of the file?

in the man page you can find 1-2048 ..but you can't make

sed -e ´1-2048s/^/frontstring/´<infile >outfile

only sed -e ´1s/^/frontstring/´<infile >outfile or

sed -e ´2048s/^/frontstring/´<infile >outfile

but not all lines....

also

for k=1 to 2048
do
sed -e ´ks/^/frontstring/´<infile >outfile
done

isn't working because there's no "to".

could help {} ?

sed -e ´{1-2048}s/^/frontstring/´<infile >outfile
 
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question