I'm trying to execute a ps
command for the servers which i'm taking it into an array and take the output of that command into a variable and then take the first line of the content again into a variable. Please find below my code.
#!/bin/bash
echo "enter the servers names..."
read -a array
for i in "${array[@]}"
do
content=`ps -auxwww | grep $i`
line=${head -1 content}
echo $line
done
exit 0
I'm unable to take the first line from the $content
. Kindly help on how to extract the first line again into a variable and then display the first line fully. I don't want to create a new file to save the contents. I would like to do it in one go.