Search code examples
sedfastq

rename fastq file headers using sed command


I am trying to rename the fastq header and add "/1" at the end of fastq header using sed commmand. Here is my code:

sed i '1~4 s/$/\\1/g' seq/*_1.fq

But no change has been made. Does someone know how to solve this? Thanks!


Solution

  • This will add /1 to line n * 4 + 1 where n >= 0 for the files matching the glob seq/*_1.fq:

    sed -i '1~4s/$/\/1/' seq/*_1.fq
    

    You did not provide any input to here is what I used:

    a
    b
    c
    d
    e
    f
    

    and the result was:

    a/1
    b
    c
    d
    e/1
    f