The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
GnuWin32 2.4.12 (LibArchive branch) iBot Software Releases - RSS News 0 05-10-2008 07:40 PM
regexp help TinCanFury Shell Programming and Scripting 0 04-06-2008 07:21 PM
tcl: regexp matching special character sumitgarg Shell Programming and Scripting 6 01-09-2008 06:00 PM
regexp with sed again!!! andy2000 Shell Programming and Scripting 2 05-03-2007 11:15 AM
regexp penfold UNIX for Advanced & Expert Users 1 06-28-2005 08:45 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-22-2005
Simerian Simerian is offline
Registered User
  
 

Join Date: Oct 2003
Location: United Kingdom
Posts: 37
GnuWin32 sed 4.1.4 regexp matching

I am using GnuWin32 sed and am having trouble with the regexp - i.e., they don't behave the same way as in UNIX (POSIX and and all that). I have a stream of data, e.g.:

11111'222?'22'33?'333'44444'55555'

I want to insert a \n after those apostrophes that are *not* preceded by a ?.

Expected output:

11111'
222?'22'
33?'333'
44444'
55555'

I used the substitution:

s/\([^?]\)'/\1'\n/g

this should be OK but it didn't work... it replaced those that *did* have a ? in front - I want the opposite.

Any gurus with a suggestion? (apart from sticking to UNIX)
  #2 (permalink)  
Old 06-22-2005
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,235
I can't imagine that that code did what you want in Unix either.

You need to escape your single quotes for them to be recognised as characters in the file and not as quotes around part of the command.
  #3 (permalink)  
Old 06-23-2005
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,409
Seems to work fine...
Code:
$ sed --version
GNU sed version 4.1.4
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.

$ head file1 sed1
==> file1 <==
11111'222?'22'33?'333'44444'55555'

==> sed1 <==
s/\([^?]\)'/\1'\n/g

$ sed -f sed1 file1
11111'
222?'22'
33?'333'
44444'
55555'
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0