I am receiving an input from the user which looks like follows:
echo +++Your input:+++
read USER_INPUT
The way I should use it is to retrieve the full name of a folder which starts with that input, but that contains other stuffs right after. All I know is that the folder is unique.
For example:
User input
123456
Target folder
/somepath/someotherpath/123456-111-222
What I need
MYNEED=123456-111-222
I was thinking to retrieve this with an MYNEED=$(ls /somepath/someotherpath/$USER_INPUT*)
, but if I do this I will get instead all the content of /somepath/someotherpath/123456-111-222
because that's the only folder existing with that name so the ls
command directly goes to the next step.
May I have your idea to retrieve the value 123456-111-222
into a variable that I will need to use after?