I have a trivial problem with regular expression in bash.
#!/bin/bash
FNAME=$1
echo ${FNAME//.*\/tests\//}
I want to remove everything before /test/ including the /test/ as well. Because of some reasons “.*” doesn’t work.
$ ./eclipse/unittest.sh /foo/tests/bar
/foo/tests/bar
How do I select anything in bash reg exp?
You can use
#followed by a pattern to remove everything up to and including the pattern. It will use the shortest match:If you want to use the longest match, you can use
##: