Open NicholasMontalbano opened 6 years ago
next time: use backticks to enclose your code. it will appear nicer, with colors if you say it's bash/shell, and it might be useful if the code contains some *
that would otherwise be interpreted as a sign to italicize what follows (in which case these stars are not shown).
Hey @cecileane and @coraallencoleman, here are my solutions using sed!
Task 1 .
gsed -E -i 's/^([^,]+),"([^,]+),([^,]+),([^,]+)"/\1,\2\3\4/' tableofSNPs.csv
# Will break in the case of 'Minimum' above 9 digits
Check:
sed 's/[^,]//g' tableofSNPs.csv | uniq -c # 3359 rows with three commas in each (3359*3)
Extra task .
sed -e -i 's/A/?/g' -e 's/T/A/g' -e 's/?/T/g' tableofSNPs.csv # Assumes there are no ‘?’ characters in the file
Check:
grep -o "A" tableofSNPs.csv | uniq -c; grep -o "T" tableofSNPs.csv | uniq -c # Run before and after one liner to make sure numbers switch; doesn’t work if the number of A’s and T’s are the same to begin with
Thanks!