[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: OT: help with text file?



Mikkel L. Ellertson wrote:
>> I see your grep and raise you a sed:
>>
>>   sed 's/.*[^0-9]//' foo.txt >new_file.txt
>>
> What happens if there is a number in the middle of the line of text,
> as well as at the end? Wouldn't that give you more text then desired?

No, because .* is greedy.  The .* will consume all but the very last
non-numeric character (including numeric chars before the last
non-numeric), then [^0-9] will consume the last non-numeric char.

Matt Flaschen


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]