0

I have an Ubuntu 12.04 server here and I have a process that can use some ports in my system.

The way I have to track these ports is this command:

ps ax | grep thin | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}\:[0-9]{1,5}'

Now I want to use this command as an array variable in a shell script.

How do I parse the values there to an array?

The value looks like this:

0.0.0.0:3000 0.0.0.0:3001 0.0.0.0:3002 0.0.0.0:3003

Thanks!

Apollo
  • 1,913
  • 2
  • 19
  • 26

1 Answers1

2

To put the output of your command into an array:

array=( $(ps ax | grep thin | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}\:[0-9]{1,5}') )
dogbane
  • 266,786
  • 75
  • 396
  • 414