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!

1

1 Answer 1

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}') )
Sign up to request clarification or add additional context in comments.

1 Comment

Wow.. that was simple! Thanks a lot! =D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.