Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asking a sed guru

Status
Not open for further replies.

iribach

Technical User
Oct 12, 2002
211
CH
Code:
#n
/adr0/,/adrX/p
this works perfect, as expected, suppose it
prints:
Code:
aaa
bbb
ccc
Q: how join the output lines to 1 string: like
Code:
aaabbbccc
with endind '\n' ?
sed has (maybe i have) problems with '\n'
tia
 
PS:
no problems doing it in AWK, PERL or C
SED is required :(
 
Code:
sed 's/.*$/aaabbbccc/g;q' input
works like a charm :)

for real: why only use sed?
Is tr allowed?
Code:
cat abc.file | tr -d "\n"

Well - Helmut Herold, "awk und sed", Addison Wesley, 1997, p. 233 says:
(sedfile: repnl.sed)
Code:
/^[a-zA-Z]*$/H
/^[a-zA-Z]*$/d
H
g
s/\([a-zA-Z]*\)\n/\1/g
sed -f repnl.sed abc.file

Don't expect explanation.

seeking a job as java-programmer in Berlin:
 
Code:
#n
/adr0/,/adrX/H
/adrX/{g;s/\n//g;p;d;}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top