Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I assign the result of eval to variable in bash script?

I have a bash script that returns a list, which is what I want, but I need to put the results in a variable so I can operate on them one at a time in a for loop.

#!/bin/bash
processID="ps aux | grep `date +"%b"` | gawk '{print \$2}'"

eval $processID

How do I assign the result of eval to a variable? Thanks

like image 561
jimd Avatar asked Nov 04 '22 02:11

jimd


1 Answers

pid=$( ps aux | grep `date +"%b"` | awk '{print $2}' )
like image 60
Alessandro Pezzato Avatar answered Nov 09 '22 10:11

Alessandro Pezzato