I want to read a value from a known file.
File is located at /root/.my.cnf and contains
[client]
password='PosftGlK2y'
I would like to return PosftGlK2y - ideally using a simple one liner command.
I have tried
cat /root/.my.cnf | grep password
which returns password='PosftGlK2y'
I am sure there is a better way.
You can skip the
catandgrepdirectly, and then pipe toawkwith a'delimiter.Alternately, you can skip the grep altogether and just use
awkto do the search and the extraction.