Tuesday, April 18, 2017

Vim: Apply some operation with external command on each line



Say I have below list of numbers those are some file size in KBs and I want to
convert them to GB:
801466311
694975337
116332661
636558230
1776193937
2576588352
202358013
2041308660
1966184154
9249101106
7014864623
14710830460
2576588352

these numbers are in KBs say I want them in GBs
visually select the lines by pressing Shift+V

g/^/exe ".!sed -e 's/.*/&\\/(1024*1024)/' | bc -l"

Followers