bash - String Manipulation in UNIX -


After running I have a script which will show:

  square 1 area 10 Square is made with Square box 2 with name box with field 20. Circle name is not made with Spiny Area 22, area with area has been rectangle with tri-three-area 30.   

How can I get all the numbers between the fields and create and store it in an array?

The stored array will be:

  10 20 30   

The hard part is that, I can not find just the first number, just like That square (1) will be read, I can not even take the number between "field", and "is" because it can take in sizes that have not been created. Any idea how to do this?

use of grep :

  $ Cat testfile Square 10 is named Square with area area named Square 2 with Area 20, Square 2 is created with name box. Circle's name is not created with spin area 22 with rectangle area with name Tri 30 has been built. $ Grep -Eo 'area [0-9] + has been created' testfile | Grep -Eo '[0-9] +' 10 20 30   

Note POSIX does not support grep -o , but It should work on BSD and GNU grip.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -