I'll be getting a directory path as the input to the script.
E.g. 1 abc/fsg/sdfhgsa/fasgfsd/adfghad/XXX/fhsad
e.g. 2 sadfg/sadgjhgds/sd/dtuc/cghcx/dtyue/dfghsdd/XXX/qytq
This input will be stored in a variable.
My query is how to extract the field in a variable VAR which occurs just before XXX
Please note that XXX position is not fixed in the directory path.
YOUR MAKING IT TOO HARD. Use Korn/Bash built-in variable operators.
## #EXPRESSION RESULT
#/home/david/waffen/long.file.name
#${path%%.} /home/david/waffen/long
#${path%.} /home/david/waffen/long.file
#${path} /home/david/waffen/long.file.name
#${path#//} /david/waffen/long.file.name
#${path##//} long.file.name
#${path##*/} long.file.name
###