regex - AWK file to split a column into two at space -


i want take csv file , use awk split column 2 parts. column $11 , contains words seperated space.

i trying use

`awk -f ' ' -v ofs='|' '{ "$11=$11"; print }' | \` 

i want take column 11, split 2 using | delimiter, , print results.

the results -

input

1|2|3|4|5|6|7|8|9|10|11|12|13|14|15 100|cat|dog|sam|123|12345|11|g|sam sheparm|2121212|15*666ba  dangers of cat ownership|4/28/13|4/21/16|act|132132132132 

expected output

 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16  100|cat|dog|sam|123|12345|11|g|sam sheparm|2121212|15*666ba|dangers of cat ownership|4/28/13|4/21/16|act|132132132132 

what awk command split specific column, number 11, 2 prices using space. why isn't awk command working? column 11 1 looks 15*666ba dangers of cat ownership. need split down middle space 2 columns.

you may try below awk command.

$ awk -f'|' -v ofs="|" '{sub(/ +/,"|",$11)}1' file 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15 100|cat|dog|sam|123|12345|11|g|sam sheparm|2121212|15*666ba|dangers of cat ownership|4/28/13|4/21/16|act|132132132132 

this replace first 1 or more spaces pipe in 11th column.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -