I have a file.txt that contains the single line:
[MOVING] From [/source/foo.txt] to [/dest/bar.txt] I would like to find a regex that basically extract the third group inside a pair of square brackets []
expecting /dest/bar.txt
So far, I came up with:
$> cat file.txt | grep ".*From.*to.*" | grep -oP '(?<=to ).*$' | cut -d "[" -f 2 | cut -d "]" -f 1 which works but doesn't like an elegant solution at all. Does anyone have an idea on how to achieve that ?