Sunday, 15 February 2015

Modify text in columns using linux commands -



Modify text in columns using linux commands -

i have tab delimited file columns shown below.

chr1 899766 899766 g t exonic;exonic klhl17 . nonsynonymous snv;nonsynonymous snv

i want delete text after ";" in columns 6 , 9. output should like:

chr1 899766 899766 g t exonic klhl17 . nonsynonymous snv

could give linux command solve this. should delete after ";" in specified columns.

you can utilize next sed command:

sed 's/;[^\t]\+//g' your-log-file > new-file-name

this means "delete after semicolon (but not including) next tab". output go new-file-name. if want edit your-log-file in-place (once sure command works way want to, can following:

sed -i 's/;[^\t]\+//g' your-log-file

you can utilize awk, although less familiar program. here brief overview: http://www.cyberciti.biz/faq/howto-delete-word-using-sed-under-unix-linux-bsd-appleosx/.

linux text text-files

No comments:

Post a Comment