Skip to main content
1 of 4
ugm6hr
  • 33
  • 1
  • 4

Calculate and round numbers up in bash

I'm struggling with a slight variation on: How to calculate by taking first field and How to round floating point numbers in shell?

I have a file that looks like (space between columns):

1533 C_P.doc
691 C_M.doc
905 G_S.doc
945 J_Z.doc
1549 J_M.doc
1701 L_B.doc

I want to take the column of numbers and divide each number by 65 (but round up), and add a new column (ideally to left) with these numbers included. i.e.

24 1533 C_P.doc
11 691 C_M.doc
14 905 G_S.doc
15 945 J_Z.doc
24 1549 J_M.doc
27 1701 L_B.doc

I would like this in a bash script. Is it possible? If necessary, the middle column can be removed if that makes it easier.

All assistance gratefully received.

[Ubuntu 14.04]

ugm6hr
  • 33
  • 1
  • 4