I have a string which looks something like this
But it can also look like
Now, I am making a script where
$P is the full path to the directory were
Now I use this
To be replace anything that ends with txt and comes after a
/. This works fine when there is something like
dir/file.txt, but not any of my other examples. How can I fix so that it matches what I want?
I don't want to match any subdirectories before
.*txt. I want to remove only the file base name.