defekas17
defekas17

Reputation: 171

how to add secuential number getting output with jq

I'm getting some values with jq command like these:

curl xxxxxx | jq -r  '.[] | ["\(.job.Name), \(.atrib.data)"]' | @tsv' | column -t -s ","

It gives me:

AAAA     PENDING
ZZZ      FAILED BAD

What I want is that I get is a first field with a secuencial number (1 ....) like these:

1     AAA        PENDING
2     ZZZ        FAILED BAD
......

Do you know if it's possible? Thanks!

Upvotes: 0

Views: 31

Answers (1)

peak
peak

Reputation: 116880

One way would be to start your pipeline with:

range(0;length) as $i | .[$i] 

You then can use $i in the remainder of the program.

Upvotes: 1

Related Questions