I can't figure out what is the problem with my following bash script:
#!/bin/bash
function jsonValue() {
    key=$1
    num=$2
    awk -F"[,:}]" '{for(i=1;i<=NF;i++){if($i~/'$key'\042/){print $(i+1)}}}' | tr -d '"' | sed -n ${num}p
}
json='{"_id": "dummy_id","title": "dummy_title"}'
id=$(echo $json | jsonValue _id)
title=$(echo $json | jsonValue title)
echo ${id}/${title}
The result is:
dummy_id title/ dummy_title
The function result does not contain space. Have you any idea what is the problem with the function?
 
    