Does it work with GNU sed? (No change in result when I tried)
I did the following
sed '/^@HISEQ/s/\/1//' in.fq
Hi,
I have a file looking like this
@HISEQ:229:C81CCANXX:1:1101:10157:17161/1
AAAAAAAAAAAAAAAAAAAA
+
CCCCCGGGG/1GGGGGGCEEG
@HISEQ:229:C81CCANXX:1:1101:10741:22239/1
GCCTTGCTATTGACTCTACT
+
BBBB@EEGGGGGDGGEGGGG
@HISEQ:229:C81CCANXX:1:1101:10901:88419/1
GCTTAGGGATTTTATTGGTA
I would like to remove this /1 at the end of the lines (read names).
I did
sed -i -e 's/\/1//g' MyFile.txt
But the problem is that is also removes the /1 occurring in the middle of the 4th line (sequence quality).
Is there a way to substitute the /1 only on lines starting with @HISEQ (a sort of conditional expression) ?
I also tried:
awk -F "/" '/^@HISEQ/{ $2 = "" ; print $0 }' essai.change.name> file.txt
The problem then is that I have only the @HISEQ lines and I loose the lines in between.
Thank you!
C. Anna
'$' for end of the line:
sed 's%/1$%%'
Is there a way to substitute the /1 only on lines starting with @HISEQ
sed '/^@HISEQ/s%/1$%%'
Does it work with GNU sed? (No change in result when I tried)
I did the following
sed '/^@HISEQ/s/\/1//' in.fq
$ echo -e "@HISEQa\1\nx\1" | sed '/^@HISEQ/s/\\1//'
@HISEQa
x\1
$ sed --version
sed (GNU sed) 4.2.2
This one
sed '/^@HISEQ/s%/1$%%'
worked perfectly! Thank you
I would like to make sure I understand the syntax though.
It says: for the lines starting with @HISEQ (^@HISEQ), delete (s%), the character "1" (1$%%). Is this right ?
I'm not sure to understand the function of the %%
sed 's%a%b%' is the same than 's/a/b/' using '%' instead of '/' make it simplier because I don't need to escape things. e.g: 's%http://google.com/%url%'
Log in to answer this question.
Avoid the -i flag on sed if you are not sure what you are doing, better would be to just pipe the result to e.g. head to check if the command performed as you thought.