Home > other >  How to store id Command to JSON file in Linux with bash
How to store id Command to JSON file in Linux with bash

Time:04-16

I have the id command and I want to store the output of the id command in the JSON file like

{
id : uid=0(root) gid=0(root)
}

How to do that

CodePudding user response:

Use to generate JSON

jq --arg id "$(id)" --null-input '$ARGS.named' > file.json

CodePudding user response:

This could be the simplest answer:

echo "{ \"id\": \"$(id)\" }" > file.json

But your question does not offer any specific info..so I am just guessing how you are trying t pull the info, how or where you need it...etc.

  • Related