#bash (2020-04)

A channel for bash scripting

2020-04-22

2020-04-20

Hemanth avatar
Hemanth

How do i jq only the values of the Name, if the json is like this

[
    [
        {
            "Name": "AB"
        }
    ],
    [
        {
            "Name": "BA"
        }
    ],
    [
        {
            "Name": "CD"
        }
    ],
] 
bradym avatar
bradym

jq '.[][].Name'

:--1:1
Hemanth avatar
Hemanth

ty

2020-04-08

Shawn Petersen avatar
Shawn Petersen

Hi all, hoping for some help. I need a regex to pull only the second occurence of the result of this expression.. grep -Po ‘(?<=<version>)(\d.+.+?)(?=</version>)’ file.xml

so far nothing is working and I get all 17 results from the file.

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

One quick way:

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)
grep -Po '(?<=<version>)(\d.+.+?)(?=</version>)' file.xml | head -2 | tail -1
Shawn Petersen avatar
Shawn Petersen

lol yep that works

Shawn Petersen avatar
Shawn Petersen

sometimes have to think outside the box

Shawn Petersen avatar
Shawn Petersen

thanks man!

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

no prob!

2020-04-07

    keyboard_arrow_up