I am executing a script in bash profile and having file path as follows:
$FilePath=$HOST_NAME_LAND/home/chandan/abc.txt
where $HOST_NAME_LAND is an environment variable which points to the server name.
export $HOST_NAME_LAND=//<server name>
The environment variable name and server name may vary for different modules.
What I need is to separate the file path( /home/chandan/abc.txt ) from the environment variable( $HOST_NAME_LAND ), to check the existence of the file on that server?
This is not going to resolve the issue because the environment variable name, file name and file path will vary module wise. So, I need a more generic approach.
This assumes that the expansions of HOST_NAME_LAND and the other evn variables containing the server name starts with // (as per your OP) and they only contain alphabets.
Which language/shell are you using? the above is not a valid shell syntax.
Also, as others asked, if you want to be generic, please provide the criteria based on which the file name can be extracted.