I have this file and i want to only get the value of testme= So that i can do another action. But this throws lots of lines and actually cant yet make it work.
#!/bin/bash
for i in $(cat /var/tmp/test.ini); do
# just one output i need: value1
grep testme= $i
done
; comments
testme=value1
; comments
testtwo=value2
How about
#!/bin/bash
grep 'testme=' /var/tmp/test.ini | awk -F= '{ print $2 }'
or alternatively just using bash
#!/bin/bash
regex='testme=(.*)'
for i in $(cat /var/tmp/test.ini);
do
if [[ $i =~ $regex ]];
then
echo ${BASH_REMATCH[1]}
fi
done