This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Deleting an illegal character (') in taxon names from many nexus alignments using tr -d

Hello,

I want to remove the chacater ' (apostrophe) from a taxon name in all my nexus alignments (~600). I got it worked for a single file but I need help to put this into a loop. Any help on this is appreciated. Following worked for a single file. tr -d "'" < test.nex > testX.nex

Following are what I tried for loops, but nothing worked!

for filename in *.nex; do
   tr -d "'" $filename;`
done

for filename in $(cat *.nex) do;
   'tr -d "'"' $filename > $filename.new
done

tr -d "'" < *.nex

Thanks!

tr -d deleting character

1 answer

Have you tried for filename in *.nex; do cat ${filename} | tr -d "'" ${filename} > ${filename}.new; done?

It worked with a little modification Genomax. Thanks! I used following with a just an extra <

for filename in *.nex; do
   cat ${filename} | tr -d "'" < ${filename} > N_${filename};
done

Log in to answer this question.