Hello,
Does anyone know of a command (in the linux command line) such as sed to remove white spaces from a specific field only? In my case, I have 2 tab-seperated fields in the format shown below and I would like to remove the white space from the beginning of the second field (the beginning of the sequence) without removing white spaces from the first field. It is a fasta format but I can convert it into a tab delimited text file if needed.
>10_GL0000024 root|cellular organisms|Bacteria|Firmicutes locus=scaffold18562_3:3421:4365:- [Complete]
MELTFQTATPAERLYTTGQSMQIEGQMGYIGCLQTGMSEDGKGAFPKWSSGREGLNTEEFQQELAGVMDALIHDEQYGGFLKDSDAMRDFCQTHPESGFNNGFAFGFRADTAQYSYLIRLNPCKGEENLSICCYRRDWLDSHMKHAEKGIRFITPHYKEKFRIADGDKVRIRRFDGQVFDRVCRYIDDCHVEIGSELYHICQFAEIMERNGNSVIPLRSSLPFVCYGKVPEKRAIVMFERGFDGYRSASFATKGRTSQKLVDELNGELGVTKAQAAAMQGGATQGWASPAADPKNYDEQGQPIKPRHRDRGDAR
Thank you! Angie
2 answers
Take a look at regex anchors, which tie your pattern to the beginning or end of a line. You can use sed to remove whitespace at the beginning of a line only using "^", which anchors the pattern to the beginning of the line.
sed 's/^[\t ]*//' file.fa > secondFile.fa
if this is a fasta file, then you'll always want to remove leading whitespace, so something like:
sed 's/^\s//' myfile.fa
oughta work fine
Log in to answer this question.