bed file in bad format
Hi,
i have a bed file, when i use cat -e
chr4 177604691 177713895 $
chr1 223967595 224033674 $
chr1 43766566 43788781 $
chr16 11361714 11363160 $
chr11 120973375 121061515 $
chr4 70706930 70725870 $
chr9 108424738 108425385 $
can any one help me to delete the "" at the end of lines ?
Thank you.
• 1,961 views
•
link
3 answers
The awk command can be used to strip off trailing whitespace.
Compare:
$ echo -e "chrN\t100\t200\tfoo " | cat -e
chrN 100 200 foo $
with:
$ echo -e "chrN\t100\t200\tfoo " | awk 'BEGIN{OFS="\t"}{print $1,$2,$3,$4}' | cat -e
chrN 100 200 foo$
For a three-column file:
$ awk 'BEGIN{OFS="\t"}{print $1,$2,$3}' bad.bed3 | sort-bed - > good.sorted.bed3
• 0 views
•
link
If you just want to remove columns, the cut command is the simplest approach:
echo -e "chrN\t100\t200\tfoo " | cut -f 1-3
• 0 views
•
link
sed 's/\ $//g' your_file > new_file should also work.
• 0 views
•
link
Log in to answer this question.