Hi Team,
I want to read a file line by line and print the data in multiple variables.
By using below script i am doing that but i want to increase the performance by using for loop Can someone let me know how to do that ?.
Below is my script:
ps aux > /tmp/test
sed 1d /tmp/test > /tmp/test1
while IFS= read -r line;
do
USER=$(echo "$line"|awk '{print $1}')
CPU_percentage=$(echo "$line"|awk '{print $3}')
echo -e "{\"'PID'\":\"'"$PID"'\",\"'CPU_percentage'\":\"'"$CPU_percentage"'\"}"
done < /tmp/test1
How to use for loop for above script to get more performance from the shell script ?.