I have the following cases:
case@test.com
case_1_2@test.com
case_1@test.com
I'm trying to convert these to
case@test.com
case@test.com
case@test.com
So it should remove everything from the first '_' (including it) to the @ (not including that).
I have something, but it doesn't really work correctly:
Based on this thread: Cut based on Two Delimiters at one go, and this U&L Q&A: Splitting string by the first occurrence of a delimiter.
sed 's/^.*_\([^ ]*\) .*\@\([^$]*\)$/\1 \2/' infile
But no luck. Anyone want to take a chime at it?
read
with-r
and without setting IFS) – Stéphane Chazelas Aug 22 '13 at 20:01