Skip to main content
added 3 characters in body
Source Link
muru
  • 78k
  • 16
  • 212
  • 318

Take a look at the jq command it is a command line json parser. You can pull any field you would like.

https://www.systutorials.com/docs/linux/man/1-jq/

For example this will return the java_version number.

cat variable.json | jq .java_version

cat variable.json | jq .java_version

If you prefer using core commands so you don't have to install anything you can use this command.

cat input | grep java_version | awk '{print $NF}'

cat input | grep java_version | awk '{print $NF}'

Shorter version of the above command before someone says you don't have to cat into grep.

grep java_version variable.json | awk '{print $NF}'

grep java_version variable.json | awk '{print $NF}'

EDIT: Another option would be.

sudo yum install -y jenkins-$(grep java_version variable.json | awk '{print $NF}' | sed 's/"//g')-openjdk

sudo yum install -y jenkins-$(grep java_version variable.json | awk '{print $NF}' | sed 's/"//g')-openjdk

Take a look at the jq command it is a command line json parser. You can pull any field you would like.

https://www.systutorials.com/docs/linux/man/1-jq/

For example this will return the java_version number.

cat variable.json | jq .java_version

If you prefer using core commands so you don't have to install anything you can use this command.

cat input | grep java_version | awk '{print $NF}'

Shorter version of the above command before someone says you don't have to cat into grep.

grep java_version variable.json | awk '{print $NF}'

EDIT: Another option would be.

sudo yum install -y jenkins-$(grep java_version variable.json | awk '{print $NF}' | sed 's/"//g')-openjdk

Take a look at the jq command it is a command line json parser. You can pull any field you would like.

https://www.systutorials.com/docs/linux/man/1-jq/

For example this will return the java_version number.

cat variable.json | jq .java_version

If you prefer using core commands so you don't have to install anything you can use this command.

cat input | grep java_version | awk '{print $NF}'

Shorter version of the above command before someone says you don't have to cat into grep.

grep java_version variable.json | awk '{print $NF}'

EDIT: Another option would be.

sudo yum install -y jenkins-$(grep java_version variable.json | awk '{print $NF}' | sed 's/"//g')-openjdk
added 141 characters in body
Source Link

Take a look at the jq command it is a command line json parser. You can pull any field you would like.

https://www.systutorials.com/docs/linux/man/1-jq/

For example this will return the java_version number.

cat variable.json | jq .java_version

If you prefer using core commands so you don't have to install anything you can use this command.

cat input | grep java_version | awk '{print $NF}'

Shorter version of the above command before someone says you don't have to cat into grep.

grep java_version variable.json | awk '{print $NF}'

EDIT: Another option would be.

sudo yum install -y jenkins-$(grep java_version variable.json | awk '{print $NF}' | sed 's/"//g')-openjdk

Take a look at the jq command it is a command line json parser. You can pull any field you would like.

https://www.systutorials.com/docs/linux/man/1-jq/

For example this will return the java_version number.

cat variable.json | jq .java_version

If you prefer using core commands so you don't have to install anything you can use this command.

cat input | grep java_version | awk '{print $NF}'

Shorter version of the above command before someone says you don't have to cat into grep.

grep java_version variable.json | awk '{print $NF}'

Take a look at the jq command it is a command line json parser. You can pull any field you would like.

https://www.systutorials.com/docs/linux/man/1-jq/

For example this will return the java_version number.

cat variable.json | jq .java_version

If you prefer using core commands so you don't have to install anything you can use this command.

cat input | grep java_version | awk '{print $NF}'

Shorter version of the above command before someone says you don't have to cat into grep.

grep java_version variable.json | awk '{print $NF}'

EDIT: Another option would be.

sudo yum install -y jenkins-$(grep java_version variable.json | awk '{print $NF}' | sed 's/"//g')-openjdk

added 150 characters in body
Source Link

Take a look at the jq command it is a command line json parser. You can pull any field you would like.

https://www.systutorials.com/docs/linux/man/1-jq/

For example this will return the java_version number.

cat variable.json | jq .java_version

If you prefer using core commands so you don't have to install anything you can use this command.

cat input | grep java_version | awk '{print $NF}'

Shorter version of the above command before someone says you don't have to cat into grep.

grep java_version variable.json | awk '{print $NF}'

Take a look at the jq command it is a command line json parser. You can pull any field you would like.

https://www.systutorials.com/docs/linux/man/1-jq/

For example this will return the java_version number.

cat variable.json | jq .java_version

If you prefer using core commands so you don't have to install anything you can use this command.

cat input | grep java_version | awk '{print $NF}'

Take a look at the jq command it is a command line json parser. You can pull any field you would like.

https://www.systutorials.com/docs/linux/man/1-jq/

For example this will return the java_version number.

cat variable.json | jq .java_version

If you prefer using core commands so you don't have to install anything you can use this command.

cat input | grep java_version | awk '{print $NF}'

Shorter version of the above command before someone says you don't have to cat into grep.

grep java_version variable.json | awk '{print $NF}'

added 165 characters in body
Source Link
Loading
added 2 characters in body
Source Link
Loading
Source Link
Loading