i'm trying to extract a specific string from a grep output
uci show minidlna
produces a large list
.
.
.
minidlna.config.enabled='1'
minidlna.config.db_dir='/mnt/sda1/usb/db'
minidlna.config.enable_tivo='1'
minidlna.config.wide_links='1'
.
.
.
so i tried to narrow down what i wanted by running
uci show minidlna | grep -oE '\bdb_dir=\S+'
this narrows the output to
db_dir='/mnt/sda1/usb/db'
what i want is to output only
/mnt/sda1/usb/db
without the quotes and without the starting "db_dir" so i can run rm /mnt/sda1/usb/db/file.db
i've used the answers found here How to extract string following a pattern with grep, regex or perl and that's as close as i got.
EDIT: after using Ed Morton's awk
command i needed to pass the output to rm
command.
i used:
| ( read DB; (rm $DB/files.db)
.
read DB
passes the output into the vairable DB
.
(...)
combines commands.
rm $DB/files.db
deletes the the file files.db
.