Our Sponsors



Download BioinformaticsOnline(BOL) Apps in your chrome browser.




Commands to Remove White Space In Text Or String Using Awk And Sed In Linux

  • Public
By Neelam Jha 959 days ago
text=" ATGGTV AGTGACCTAGAGTGATGA G GGRTTT" echo "$text" | sed 's/ //g' OR echo "$text" | awk '{ gsub(/ /,""); print }' Return: ATGGTVAGTGACCTAGAGTGATGAGGGRTTT echo "$text" | sed 's/^ //g' echo "$text" | sed 's/ \$//g' #Multiple space cat /tmp/test.txt | sed 's/[ ]\+/ /g' echo "$text1" | awk '{ gsub(/[ ]+/," "); print }' cat /tmp/test.txt | awk '{ gsub(/[ ]+/," "); print }'