Originally Posted by catkin
It is. For a bit of fun, what would be the regex to remove only up to the first "/"?
Is this a trick question? / is the first character on the line so removing only up to the first / would be the same as removing nothing at all.
I had a play with it anyway using a list of files names where I put A at the start of each line
? makes the expression non-greedy, so I was thinking
sed 's|.*?/||' filenames.txt
But that doesn't actually have any effect at all. This
sed -r 's|.*?/||' filenames.txt
does the same as if the ? wasn't in there.
A few minutes on Google reveals that sed doesn't actually support non-greed regular expressions. So I think you have to do it by matching any number of characters which aren't a /
$ sed 's|[^/]*||' filenames.txt
Regular expressions are great. I've been using them for years and still every now and then I encounter situations where they don't work like I expect them to