![]() |
![]() |
#1 |
The list is long, but distinguished
Join Date: Dec 2006
Location: Århus, Denmark
Posts: 1,643
|
![]()
Does anyone here use sed much? I've got a bit stuck, could do with some help!
![]()
__________________
![]() |
![]() |
![]() |
![]() |
#2 |
Preparing more tumbleweed
Join Date: Jun 2006
Location: Hawaii
Posts: 6,038
|
![]()
Whatcha trying to achieve? I use it on and off here.
__________________
Mal: Define "interesting"? Wash: "Oh, God, oh, God, we're all gonna die"? |
![]() |
![]() |
![]() |
#3 |
The list is long, but distinguished
Join Date: Dec 2006
Location: Århus, Denmark
Posts: 1,643
|
![]()
Right, this is a simple example. In real times, my data is a bit hairy but the idea should work.
I have a file populated a little like this: abcdefghijklmn<<o>>pqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefg<h>ijklmnopqrstuvwxyz abcdefghijkl<<m>>nopqr<<s>>tuvwxyz abcdef<g>hijklmnopqrs<<t>>uvwxyz abcdefghijklmno<<p>>qrstuvwxyz I need to use sed to extract out anything surrounded by << >>. So ideally I'd end up with: o m s t p It's frustrating me somewhat.
__________________
![]() |
![]() |
![]() |
![]() |
#4 |
Screaming Orgasm
Join Date: Jul 2006
Location: Newbury
Posts: 15,194
|
![]()
The fact you can have more than one pattern per line caused me some major grief, but if it's OK to use sed twice, then I managed to get around that one:
Code:
sed '/\(<<[^<>]*>>\)/s//\n\1\n/g' | sed '/^<<\([^<>]*\)>>$/s//\1/p;d' Last edited by Mark; 20-06-2008 at 20:35. |
![]() |
![]() |
![]() |
#5 |
The list is long, but distinguished
Join Date: Dec 2006
Location: Århus, Denmark
Posts: 1,643
|
![]()
Thanks Mark. I've not used sed much, takes some getting used to.
__________________
![]() |
![]() |
![]() |
![]() |
#6 |
Screaming Orgasm
Join Date: Jul 2006
Location: Newbury
Posts: 15,194
|
![]()
Make sure you use the latest edit - I spotted a few bits of redundant code in the original and removed them.
|
![]() |
![]() |
![]() |
#7 | |
Rocket Fuel
Join Date: Jun 2006
Location: Adrift in the Orca
Posts: 6,845
|
![]() Quote:
__________________
![]() We must move forward not backward, upwards not forward, and always twirling, twirling, twirling... |
|
![]() |
![]() |
![]() |
#8 |
Screaming Orgasm
Join Date: Jul 2006
Location: Newbury
Posts: 15,194
|
![]()
I do wonder what that would say when translated into semaphore and back.
![]() ![]() Last edited by Mark; 21-06-2008 at 03:45. |
![]() |
![]() |
![]() |
#9 |
The list is long, but distinguished
Join Date: Dec 2006
Location: Århus, Denmark
Posts: 1,643
|
![]()
OK, second challange. This should be easy, I've nearly got it working but seem to be running in circles.
Say you have this: Code:
{.One$="One",.Number=12,.Two$="Two",.Number=13,.Three$="Three",/ A pint to whoever digs me out of sed hell #2. I really should buy a book on this...
__________________
![]() |
![]() |
![]() |
![]() |
#10 |
Preparing more tumbleweed
Join Date: Jun 2006
Location: Hawaii
Posts: 6,038
|
![]()
__________________
Mal: Define "interesting"? Wash: "Oh, God, oh, God, we're all gonna die"? |
![]() |
![]() |