sed 's/\([0-9]\{2\}\/\)\{2\}[0-9]\{2\}[ \t]\+\(.*\)[ \t]\+\$.*/\2/g'
Turns
Code:
28/11/07 SPENT ON STUFF $5
28/11/07 834637 $1,035
into
Code:
SPENT ON STUFF
834637
It will match a dd/mm/yy format followed by tabs or spaces then the account details followed by more tabs/whitespace ending with a dollar sign and then the remainder of the line and replace it with the account details (matched in brackets as region 2). Pipe your grep into the sed command and that should be it .
Edit: I'm not clear what you need any more after re-reading the OP
Sed commands can get that way, you could try removing parts of the match and seeing where it fails? I checked it on my system (sed 4.1.2), and it works fine - though if there's a different kind of whitespace in the original that would break it, for example.
My results:
Code:
[andrew@server tmp]$ cat sed.txt
28/11/07 SPENT ON STUFF $5
28/11/07 834637 $1,035
[andrew@server tmp]$ cat sed.txt | sed 's/\([0-9]\{2\}\/\)\{2\}[0-9]\{2\}[ \t]\+\(.*\)[ \t]\+\$.*/\2/g'
SPENT ON STUFF
834637
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.