I want to get output of following small shell script in json form.
#!/bin/bash
top -b -d1 -n1 | grep Cpu
Output:
Cpu(s): 6.2%us, 1.6%sy, 0.2%ni, 90.9%id, 1.1%wa, 0.0%hi, 0.0%si, 0.0%st
Required Output:
{"Cpu": "6.3" }
How can I convert output of such every shell scripts in json form ?
"Cpu""6.2%"? I suggest you add an expecting output for that line in your question, so that you could get the right answer to your question.