How to extract a part of a line by sed?
I have a variable that contains the following line of text:
someusername-sixdigitsofrandomnumbers How can I extract someusername from this line by sed? Naturally, someusername and the six digits of random numbers may change, only the '-' separator between them is always unchanged. (I could do the task in a bash script without sed, but this would be used in a procmailrc file, where I do not think the same construct would work, so I'd prefer sed) |
Code:
[chris@trevor chris]$ echo chris-123456 | sed s/[^a-z]//g in actual fact.... the username could contain numbers no? so assuming it won't have a - in it (no sure if it's actaully possbile of not.. guess it should be: Code:
[chris@trevor chris]$ echo chris-123456 | sed s/-.*//g |
I choosed the second solution, and it works.
Thanks! |
All times are GMT -5. The time now is 04:01 PM. |