gatech-kid
gatech-kid

Reputation: 67

Remove double quotes from part of string JQ

I’m having trouble removing double quotes from the date I pass in to JQ. Any idea how I can do that? -r doesn’t seem to do the trick.

curl SOMETHING | jq -r --arg date $(date +"%s") '.payload.overallStatus | [$date, .totalTimeSpent, .totalRecords, .totalDuplicates]'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   607  100   607    0     0  10649      0 --:--:-- --:--:-- --:--:-- 10649
[
  "1594330317",
  15802,
  89004346,
  10
]

(I plan to add the | @csv option to convert the output to a line of csv)

Upvotes: 1

Views: 760

Answers (1)

choroba
choroba

Reputation: 241828

Use tonumber. You need to use parentheses not to change the context for the remaining elements of the array.

[($date | tonumber), .totalTimeSpent, .totalRecords, .totalDuplicates]

Without the parentheses, the expression is equivalent to

[$date | (tonumber, .totalTimeSpent, .totalRecords, .totalDuplicates)]

Upvotes: 1

Related Questions