Consider also passing in the shell variable (EMAILID) as a jq variable (here also EMAILID, for the sake of illustration):
projectID=$(jq -r --arg EMAILID "$EMAILID" '
.resource[]
| select(.username==$EMAILID)
| .id' file.json)
Postscript
For the record, another possibility would be to use jq's env
function for accessing environment variables. For example, consider this sequence of bash commands:
[email protected] # not exported
EMAILID="$EMAILID" jq -n 'env.EMAILID'
The output is a JSON string:
"[email protected]"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…