Basic sed question
1
0
Entering edit mode
22 months ago
zhousun21 ▴ 40

Hi all,

Basic sed question:

This sed substitution works fine to replace a string of Ns with a Z:

cat test1 | sed -E "s/N{10}/Z/g"

But the reverse replaces a Z with the literal string "N{10}"

cat test2 | sed -e "s/Z/N{10}/g"

and returns something like this:

AAAAN{10}CCCCCC

I've tried to to this a variety of ways, but can't find anything that works.

Any advice will be appreciated.

fasta sed • 1.1k views
ADD COMMENT
0
Entering edit mode

what is the question ?

ADD REPLY
0
Entering edit mode

How can I replace a "Z" with 10 Ns?

(Note: I can just type in 10 Ns in the sed command, but I'm trying to understand the syntax.)

ADD REPLY
0
Entering edit mode

as far as I know, there is no 'print x time operator' in sed.

ADD REPLY
0
Entering edit mode

You could use command substitution to insert a bash seq operation as long as the sed substitution was softquoted I think, but its a hack

ADD REPLY
0
Entering edit mode
22 months ago
JC 13k

you can do with Perl:

$ echo AAAAZCCCC | perl -pe '$N="N"x10; s/Z/$N/'
AAAANNNNNNNNNNCCCC
ADD COMMENT

Login before adding your answer.

Traffic: 2487 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6