I need a solution(s) on how to change to the latest directory that has similar naming conventions as others. For example:
Folder names are as follows...
parent_directory ---> folder100.000.200
----------------------------folder100.000.201
----------------------------folder100.000.202
----------------------------folder100.000.203
Using linux shell, I'm trying to navigate to the parent_directory then to the latest folder (folder100.000.203) without having to change the script every single day (folders are added regularly).
The old solution was:
FOLDER=folder100.000.$1
cd parent_folder/${FOLDER}
But this no longer works. I understand that $1 is a positional parameter, but fail to understand why it worked previously and not now. Any help with this would be greatly appreciated.
EDIT: So I figured out the old script was passing a value into the script, which is where $1 was coming from. When I ran the script, I forgot I had to pass in the version number, but is there a way around me having to specify this?
./script.sh 203
This is the current working solution, but I still want to automate finding the number and passing it in.