presto is distributed SQL query engine ,

and when we installed the presto then it should be created the following home folder


so we can say that

in order to capture the home presto we can do ( its part of my bash script )

PRESTO_HOME=` find  /application/DB/presto/ -maxdepth 1 | grep  presto-server `

BUT ... since some users can rename the folder under /application/DB/presto/ in order to install new version

then under /application/DB/presto , we can get the following folders:


so regarding that

what is the right syntax in order to find the real path as



presto folder structure is always with

presto-server-[ any float number or integer number ]

VALID examples:


NON VALID examples:


Depending on which shell you're using, you could do it with globbing.


#! /bin/bash -
shopt -s nullglob extglob

printf '%s\n' "Found ${#dirs[@]} matching directories:" "${dirs[@]}"


#! /bin/zsh -
set -o extendedglob

printf '%s\n' "Found $#dirs matching directories:" $dirs


#! /bin/ksh93

printf '%s\n' "Found ${#dirs[@]} matching directories:" "${dirs[@]}"

For all, that's presto-server- followed by a sequence of 1 or more digits followed by 0 or more sequences of .<digits>.

  • clever with the printf '%s\n' ...! – Jeff Schaller Feb 27 '19 at 20:12
  • what is the meaning of - shopt -s nullglob extglob – yael Mar 4 '19 at 11:35

With GNU find's -regex test, you could use:

find /application/DB/presto/ -regex '/application/DB/presto/presto-server-\([0-9]*\.\)?[0-9]+'

... which requires the leading path, and then the numeric part:

  • optionally: leading digits and a period
  • one or more digits

That matches all and only your "valid" examples, and none of your "invalid" examples.

Change the [0-9]* to [0-9]+ if you want to require a digit before any leading period; the difference between:




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.