linux - How to divide one row into multiple rows? -


the data format this(separated tab):

a  1    2    3    5    6    9   b  2    3    4    6    7    8  c  5    5    7    5    6    9 

output:

a  1 2 3  5 6 9 b  2 3 4 b  6 7 8 

they separated tab. there way it?

awk -f"\t" -v ofs="\t" '{print $1, $2, $3, $4"\n" $1, $5, $6, $7}' file 

awk allows reference fields in data number, note $1 gets used twice, , returns first value line. same $2-$7. fields determined the fs (field separator variable), in case, -f input fs, while ofs output fs. both set tab char (\t).

output

a       1       2       3       5       6       9 b       2       3       4 b       6       7       8 c       5       5       7 c       5       6       9 

ihth


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -