Skip to main content
It's `-printf` that takes a `%f`.
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k

If you use

find pool -regextype posix-extended \
    -regex ".*/mypackage-([a-zA-Z0-9.]+-[0-9]{1,2})-x86_64\.pkg\.tar\.xz" \
    -exec printf '%f\n' {} + | \
egrep  grep -oEo '([a'[a-zA-Z0-9.]+-[0-9]{1,2})'

(assuming GNU grep as well), it should work for any path. The regex doesn't allow for any newlines, so there's no way to make it match for example a directory containing a similar name.

If you use

find pool -regextype posix-extended \
    -regex ".*/mypackage-([a-zA-Z0-9.]+-[0-9]{1,2})-x86_64\.pkg\.tar\.xz" \
    -exec printf '%f\n' {} + | \
egrep -o '([a-zA-Z0-9.]+-[0-9]{1,2})'

it should work for any path. The regex doesn't allow for any newlines, so there's no way to make it match for example a directory containing a similar name.

If you use

find pool -regextype posix-extended \
    -regex ".*/mypackage-([a-zA-Z0-9.]+-[0-9]{1,2})-x86_64\.pkg\.tar\.xz" \
    -printf '%f\n' |
  grep -Eo '[a-zA-Z0-9.]+-[0-9]{1,2}'

(assuming GNU grep as well), it should work for any path. The regex doesn't allow for any newlines, so there's no way to make it match for example a directory containing a similar name.

added 223 characters in body
Source Link
l0b0
  • 53.6k
  • 48
  • 225
  • 398

If you use find [...] -exec printf '%f\n' {} + | egrep -o '([a-zA-Z0-9.]+-[0-9]{1,2})'

find pool -regextype posix-extended \
    -regex ".*/mypackage-([a-zA-Z0-9.]+-[0-9]{1,2})-x86_64\.pkg\.tar\.xz" \
    -exec printf '%f\n' {} + | \
egrep -o '([a-zA-Z0-9.]+-[0-9]{1,2})'

it should work for any path. The regex doesn't allow for any newlines, so there's no way to make it match for example a directory containing a similar name.

If you use find [...] -exec printf '%f\n' {} + | egrep -o '([a-zA-Z0-9.]+-[0-9]{1,2})' it should work for any path.

If you use

find pool -regextype posix-extended \
    -regex ".*/mypackage-([a-zA-Z0-9.]+-[0-9]{1,2})-x86_64\.pkg\.tar\.xz" \
    -exec printf '%f\n' {} + | \
egrep -o '([a-zA-Z0-9.]+-[0-9]{1,2})'

it should work for any path. The regex doesn't allow for any newlines, so there's no way to make it match for example a directory containing a similar name.

Source Link
l0b0
  • 53.6k
  • 48
  • 225
  • 398

If you use find [...] -exec printf '%f\n' {} + | egrep -o '([a-zA-Z0-9.]+-[0-9]{1,2})' it should work for any path.