0

how to capture the jdk1.8.0_112 under /usr/jdk64

 /usr/jdk64/jdk1.8.0_112/

while jdk1.8.0_112 is example

and could be any other version as

jdk1.7.0_112
jdk3.8.2_112
jdk1.8.0_117
jdk1.2.0_112
jdk2.7.66_112
jdk1.8.2_111
jdk1.23.0_117
jdk9.2.093_112
3
  • 2
    Unclear: What do you mean by "capture"? Is the list that you show names of subdirectories that exists under /usr/jdk64? What is wrong with expanding the shell glob /usr/jdk64/jdk*? What are you expecting as the result (a string in a variable?)
    – Kusalananda
    Commented May 22, 2019 at 9:49
  • 1
    What’s the higher-level problem you’re trying to solve? Why do you need this particular string, and what are you planning on doing with it? Commented May 22, 2019 at 10:06
  • 1
    How is this related to bash?
    – Inian
    Commented May 22, 2019 at 10:25

2 Answers 2

1
find /usr/jdk64/* -prune -type d -name 'jdk*' | grep -P 'jdk\d+\.\d+\.\d+_\d+$'
0

One possibility for the regexp you need is:

grep -E "jdk([0-9]+).([0-9]+).([0-9_]+)"

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.