Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

I'm struggling with a slight variation on: How to calculate by taking first fieldHow to calculate by taking first field and How to round floating point numbers in shell?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.

[Ubuntu 14.04]

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.

[Ubuntu 14.04]

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.

[Ubuntu 14.04]

edited tags; edited tags
Link
Gilles 'SO- stop being evil'
  • 865.5k
  • 205
  • 1.8k
  • 2.3k
Removed question irrelevant info
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228

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]

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]

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.

[Ubuntu 14.04]

Source Link
ugm6hr
  • 33
  • 1
  • 4
Loading