How to substring
Hi,
I need a command to substring the passes content in the script file. Ex if the passes input is /local/data/temp/interface/DX7/sftpcubi/outbound/Test/file.txt I need to extract only the directory path. The value that is passed may be of any length but it is the combination of the directory path and the file name and from this input I only require to extract the file path and file name seperately. Thanks SaNv... |
Quote:
Code:
PATH=/path/to/file |
A simple way would be to search backwards through the string to find the first /, then take everything before as the directory and everything after as the filename. I'm not aware of a command that can do what you want (though perhaps someone else is), but a simple C++ program can do it the way I suggested above.
Edit: oh well, it seems there is a command! |
You can also use parameter substitution:
Code:
NAME=/path/to/some/testfile |
All times are GMT -5. The time now is 08:13 PM. |