Read a json file passed as cmd line argument

usage: myscript.sh config.json

config.json:

{
   "HOST":"abc",
   "DB_NM":"xyz",
   "USR_NM":"asd",
   "PWD":"xxx",
    .........
    .........
    .........
    ........
}

myscript.sh:


    #HOW TO SOURCE THE config.json file? 
    I would like to use the variables in config.josn file to prepare a query and execute in Linux Shell as show below. 

    host=$HOST/$DB_NM
    usr_nm="--username $USR_NM"
    pwd="--password $PWD"

    query= "--connect $host $usr_nm $pwd"
    eval $query

I am new to shell scripting. Please help me on this.

see if that helps:

awk -F '("|:)' 'NF>1 {print $2,$5}' config.json

I'm afraid there quite some open questions, like

  • which combinations from that config file entries do you need,all permutations from the 10 - 15 entries?
  • which section of the file should be used, or is there just one?
  • how are you going to use the results, source them in myscript.sh?
  • are you sure the host part and the DB part will be joined by a / ?