I am trying to create a script in linux - bash, being new to it. I would like to assign the output of the command ps -efas a variable. Can anyone help me with this? Unfortunately, the trivial myVariable = ps -efdoes not work.
ps -ef
myVariable = ps -ef
Do you want to:
myVariable=`ps -ef`
or
myVariable=$(ps -ef)
Note the absence of spaces around the '=' sign.
myVariable=$(ps -ef) # or myVariable=`ps -ef`
Try:
myVariable=`ps -ef` # back tic, upper left on most keyboards
Then the real pleasure of parsing the results can begin
myVariable = `ps -ef` or myVariable = $ (ps -ef)