#bash (2020-04)
A channel for bash scripting
2020-04-07
2020-04-08

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)
One quick way:

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

Shawn Petersen
lol yep that works

Shawn Petersen
sometimes have to think outside the box

Shawn Petersen
thanks man!

Erik Osterman (Cloud Posse)
no prob!
2020-04-20

Hemanth
How do i jq only the values of the Name, if the json is like this
[
[
{
"Name": "AB"
}
],
[
{
"Name": "BA"
}
],
[
{
"Name": "CD"
}
],
]
