Hi Dani,
I would use this regular expression with sed:
sed -E 's/\/1$//'
Test it with a piece of the file:
zcat testfile.fq.gz | head -n 24 | sed -E 's/\/1$//'
(I don't need to match on the '@' symbol because if sed doesn't match
the pattern, it won't change the line.
Then you could incorporate it into a loop like this:
ls -1 *.1.fq | while read line; do cat $line | sed -E 's/\/1$//'; done
Or, if compressed (all on one line):
ls -1 *.1.fq.gz |
while read line; do zcat $line | sed -E 's/\/1$//'; done
Then, capturing the output into a renamed file would look like this (all
on one line):
ls -1 *.1.fq.gz |
sed -E 's/\.1\.fq\.gz//' |
while read line; do zcat ${line}.1.fq.gz |
sed -E 's/\/1$//' > ${line}.fixed.1.fq.gz; done
(repeat for the *.2.fq.gz files, swapping '2' for '1' in the regular
expression pattern).
Best,
julian
Dani Dols wrote on 12/10/19 4:32 AM: