I'm having an issue with sed not returning what I expect when using a regex pattern to clean up some output from a mysql query.
mysql -uroot -p -e 'SELECT `path` FROM db.media_gallery' | sed -n -r 's/[^\/]+([^\s]+).*/\1/p'
The query returns a bunch of rows such as these:
| /media/M/W/lmt_MWS04_8.png | | /media/M/W/lmt_MWS02_11.png |
When I pipe this through the sed command listed above, it returns this:
Where did "media" go? Why does it randomly remove a part of my string?
Does anyone know how to fix my regex?