2

I want to let users select multiple layers of folders.

Once they select a version folder (Folder name similar as: 1.0.0) I will continue to do next steps.

How can I match the format like 1.0.0?

2 Answers 2

2

You can use regular expressions:

folderName="1.2.3";
matchPattern="^[0-9]\.[0-9]\.[0-9]$";

# if regex match, execute the command after "&&"
[[ $folderName =~ $matchPattern ]] && echo "Folder name matches pattern"
Sign up to request clarification or add additional context in comments.

Comments

1

You may try the below command.

grep -Po '(?foldername)\d.\d.\d'

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.