Skip to content
Advertisement

Fetching specific value from a variable in Bash

I have a variable which runs a specific bash command:

JavaScript

The output of echo $Model can be as below:

JavaScript

I want to grab only the value Model RZ230

I am using the following but it is not working:

JavaScript

Using above command I am getting output as:

JavaScript

`My output should be

JavaScript

Advertisement

Answer

Use Bash parameter expansion :

JavaScript

Regards!

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement