I am trying to find a way to pipe the result of my current script into another command which will leave me with just the last result of the array I get in my select here:
jq -r --arg name "$1" '.packageAliases | to_entries[] | select(.key | startswith($name))' sfdx-project.json the sfdx-project.json file is a json file that has a nested JSON called packageAliases, which a script adds new package version numbers and Ids to.
{ "data" : "that", "is" : "not", "really" : "necessary", "packageAliases" : { "package" : "0H0fffff", "[email protected]" : "04t0xxxxxx" } } The idea is to select all package aliases of a specific package name, and leave me with the last one, which is the one that I am supposed to use.
When I try to pipe the result I get from my select into last, I get this error: Cannot index object with number
Although I thought that the select() command returns an array (which I also get when I echo the intermediary result)
Placing the last() command anywhere else just leaves me with several null values in an array, but I still do not get the single value I actually need.
What do I need to change about my command to get the last entry from the array that I get out of select()?