awk - manipulate text using shell script? -


how can manipulate text file using shell script?

input

chr2:98602862-98725768 chr11:3100287-3228869 chr10:3588083-3693494 chr2:44976980-45108665 

expected output

2 98602862 98725768 11 3100287 3228869 10 3588083 3693494 2 44976980 45108665 

using sed can write

$ sed 's/chr//; s/[:-]/ /g' file 2 98602862 98725768 11 3100287 3228869 10 3588083 3693494 2 44976980 45108665 

or maybe use awk

awk -f "chr|[-:]" '{print $2,$3, $4}' file 2 98602862 98725768 11 3100287 3228869 10 3588083 3693494 2 44976980 45108665 

what does

  • -f "chr|[-:]" sets field separators chr or : or -. print different fields or columns.

  • you can use field separator -f [^0-9]+ makes other digits separators.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -