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
cat
andgrep
directly, and then pipe toawk
with a'
delimiter.Alternately, you can skip the grep altogether and just use
awk
to do the search and the extraction.