Extract a value from an array of data
Question:
I get such an array of data
[U8EUGGG1C32144101336_gulu, V5EUHHG1P12100100418_89011337751, V5EUHHG1P22111000028_89011337751]
How I can extract only this value "89011337751"
and write it to a variable ?
Is it possible to do it with the bash
, powershell
or other scripts?
Answers:
This is how you can achieve this in bash
#define the array
my_array=("[U8EUGGG1C32144101336_gulu]" "V5EUHHG1P12100100418_89011337751" "V5EUHHG1P22111000028_89011337751")
# extract the value and assign it to a variable
my_variable=${my_array[1]##*_}
# print the variable
echo $my_variable
I get such an array of data
[U8EUGGG1C32144101336_gulu, V5EUHHG1P12100100418_89011337751, V5EUHHG1P22111000028_89011337751]
How I can extract only this value "89011337751"
and write it to a variable ?
Is it possible to do it with the bash
, powershell
or other scripts?
This is how you can achieve this in bash
#define the array
my_array=("[U8EUGGG1C32144101336_gulu]" "V5EUHHG1P12100100418_89011337751" "V5EUHHG1P22111000028_89011337751")
# extract the value and assign it to a variable
my_variable=${my_array[1]##*_}
# print the variable
echo $my_variable