I trying to get device addres from scanimage -L which return
device `canon_dr:libusb:003:004' is a CANON DR-C125 scanner
Thanks.
I come up with this
grep -Po '`\K[^']+'
but dont understend how to properly isolate special symbols
>Solution :
You can use
grep -Po "\`\\K[^']+"
Note that inside the double quoted string literal, the backtick and backslash need escaping.
You can also use awk here:
awk -F"[\`']" '{print $2}'
See the online demo:
#!/bin/bash
s='device `canon_dr:libusb:003:004'"'"' is a CANON DR-C125 scanner'
grep -Po "\`\\K[^']+" <<< "$s"
# => canon_dr:libusb:003:004
awk -F"[\`']" '{print $2}' <<< "$s"
# => canon_dr:libusb:003:004