Re: [Guillem Jover] Parsing of dpkg status file considered harmful
Hi,
Julian Gilbey <jdg@polya.uklinux.net> wrote:
>> OK, then, replace grep with perl -ne "/\\Q$file\\E\\s/ && print" or
>> something like that.
I cannot decipher that, therefore I wouldn't put such a thing in
lmodern.
> Or simpler still, something like: fgrep $(echo -e "$file \n$file\t")
> (I haven't checked the quoting, sorry.)
Good idea, I had forgotten about this grep feature. I'm not sure,
though, why you're trying to match '$file\t'. Have you actually seen
tabs in the output of 'dpkg-query -W -f='${Conffiles}' <package>'?
I haven't, and I don't expect the format to change (since the very
purpose of dpkg-query seems to me to provide a parsable output for
programs).
Therefore, unless someone has good arguments, I'll use something like
this:
dpkg-query -W -f='${Conffiles}' "$package" \
| grep -F " $file " | cut -d ' ' -f 3
NB: I use grep -F instead of fgrep because I read long ago on a GNU
manpage (ISTR it was grep(1), but I cannot find it anymore) that
'grep -E' is preferred to egrep, 'grep -F' to fgrep, etc.
Thanks for your suggestions.
--
Florent
Reply to: