osdir.com
mailing list archive

Subject: ssed 3.62 cannot handle redirecting '>' operator correctly - msg#00086

List: editors.sed.user

Date: Prev Next Index Thread: Prev Next Index


It seems that ssed 3.62 cannot handle redirecting '>' operator
correctly when I run a substitution script with a double
quotes '\"' in lhs (or rhs) from the commandline under win2k.

eg.
-------------------
e:\bin\>cat a.txt
abc"cc
e:\bin\>ssed "s/abc\"/abcde/" a.txt
abcdecc
e:\bin\>ssed "s/abc\"/abcde/" a.txt>b.txt
ssed: can't read a.txt>b.txt: Invalid argument

-------------------
It cannot be redirect to b.txt.
If both lhs and rhs have '\"' , like this:
-------------------

e:\bin\>ssed "s/abc\"/abcde\"/" a.txt>b.txt

The script above works fine, but...
-------------------

e:\bin\>ssed "s/abc\"/abcde/" a.txt>b.txt
ssed: can't read a.txt>b.txt: Invalid argument

-------------------
I use the script above to change 'abc"' into 'abcde' but It
treat 'a.txt>b.txt' as an argument.
when I add spaces around the '>' , it just print the
output to stdout.
If both lhs and rh have '\"' , everything is OK.
*The script runs correctly using gsed 4.1.1 .

I am not sure if it is a bug, but it works differently
comparing gsed, so........

Besides, why I cannot make in-place edit with '-i' option when not
suffix is supplied?
--------------------

e:\bin\>ssed -i "s/abc/cba/" a.txt
ssed: cannot rename ./sedDOSSUX: File exists

--------------------
Is it a feature?





--

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/sed-users/

<*> To unsubscribe from this group, send an email to:
sed-users-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/







Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: quoting (was: Re: question about substitution)

digamma schreef: > Ruud H.G. van Tol: >> digamma: >>> Given a string s (not containing newlines) how do I get a regexp >>> that matches only s. >>> >>> What I thought of doing was to filter s through >>> >>> s/[][\^$]/\\&/g;s/^/^/;s/$/$/ >> Maybe also >> s/[{}()|+*]/[&]/g > {}()|+ are not needed since they are not special characters for sed. I was also thinking of a 'sed in extended regex mode'. Like the -E mode of grep. Don't know if such a beast exists though. > Laurent's solution I think is the minimal one. Add the command > delimiter to the set of special characters and quote every occurence > of these. > > s/x/[x]/g is the same as quoting with a \ for special characters but > not for the delimiter /. Yes, but the [x] notation is a better survivor. > Here's what I have now: > [...] > # for procmail > s/[[\^$.*+?|()]/\\&/g > s/.*/\\<&\\>/ For a $var not containing newlines, $\var should be sufficient. I see that you add wordboundary-matchers. $var_RE = "\<$\var\>" You don't need sed in procmail though, see my procmail code: http://www.xs4all.nl/~rvtol/procmail/ -- Grtz, Ruud -- Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/sed-users/ <*> To unsubscribe from this group, send an email to: sed-users-unsubscribe@xxxxxxxxxxxxxxx <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

Next Message by Date: click to view message preview

Re: ssed 3.62 cannot handle redirecting '>' operator correctly

On 20 Mar 2005 at 16:28, hq00e wrote: > It seems that ssed 3.62 cannot handle redirecting '>' operator > correctly when I run a substitution script with a double > quotes '\"' in lhs (or rhs) from the commandline under win2k. > > eg. > ------------------- > e:\bin\>cat a.txt > abc"cc > e:\bin\>ssed "s/abc\"/abcde/" a.txt > abcdecc > e:\bin\>ssed "s/abc\"/abcde/" a.txt>b.txt > ssed: can't read a.txt>b.txt: Invalid argument > > ------------------- > It cannot be redirect to b.txt There are two immediate solutions to your problem. (1) Use the DOS/Windows alternative of putting the redirection in front of the command. Since redirection is accomplished first, it makes no difference if you put the redirect arrows in front of the command or after it. This trick goes back to DOS 3.0, at least. Thus: >b.txt ssed "s/abc\"/abcde/" a.txt (2) Use the hex representation of a double quote, \x22, when you need to represent it in the text. Thus: ssed "s/abc\x22/abcde/" a.txt >b.txt > *The script runs correctly using gsed 4.1.1 . Are you using Cygwin sed? Because I get the same results with GnuWin32 sed. > e:\bin\>ssed -i "s/abc/cba/" a.txt > ssed: cannot rename ./sedDOSSUX: File exists > > -------------------- > Is it a feature? It would be nice if the Windows version worked the same as the Unix version, but they don't. For the time being, the "workaround" is to always include an extension for backup files, and then if you want, just delete the files with those extensions. E.g., ssed -i.DELETEME "s/your/script/" *.txt del *.DELETEME It's a workaround. -- Eric Pement -- Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/sed-users/ <*> To unsubscribe from this group, send an email to: sed-users-unsubscribe@xxxxxxxxxxxxxxx <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

Previous Message by Thread: click to view message preview

How to split up a big file...?

Hi members I have a big file containing blocks, separated by ... BeginBlock ... ... ... EndBlock ... ... BeginBlock ... ... ... EndBlock ... Is it with sed possible to separate each block into an own file, e.g. file001.txt for first BeginBlock..EndBlock section, file002.txt for second and so on... The number of blocks is variable, due to different "big files". I really would appreciate any help. Cheers, Roland -- Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/sed-users/ <*> To unsubscribe from this group, send an email to: sed-users-unsubscribe@xxxxxxxxxxxxxxx <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

Next Message by Thread: click to view message preview

Re: ssed 3.62 cannot handle redirecting '>' operator correctly

On 20 Mar 2005 at 16:28, hq00e wrote: > It seems that ssed 3.62 cannot handle redirecting '>' operator > correctly when I run a substitution script with a double > quotes '\"' in lhs (or rhs) from the commandline under win2k. > > eg. > ------------------- > e:\bin\>cat a.txt > abc"cc > e:\bin\>ssed "s/abc\"/abcde/" a.txt > abcdecc > e:\bin\>ssed "s/abc\"/abcde/" a.txt>b.txt > ssed: can't read a.txt>b.txt: Invalid argument > > ------------------- > It cannot be redirect to b.txt There are two immediate solutions to your problem. (1) Use the DOS/Windows alternative of putting the redirection in front of the command. Since redirection is accomplished first, it makes no difference if you put the redirect arrows in front of the command or after it. This trick goes back to DOS 3.0, at least. Thus: >b.txt ssed "s/abc\"/abcde/" a.txt (2) Use the hex representation of a double quote, \x22, when you need to represent it in the text. Thus: ssed "s/abc\x22/abcde/" a.txt >b.txt > *The script runs correctly using gsed 4.1.1 . Are you using Cygwin sed? Because I get the same results with GnuWin32 sed. > e:\bin\>ssed -i "s/abc/cba/" a.txt > ssed: cannot rename ./sedDOSSUX: File exists > > -------------------- > Is it a feature? It would be nice if the Windows version worked the same as the Unix version, but they don't. For the time being, the "workaround" is to always include an extension for backup files, and then if you want, just delete the files with those extensions. E.g., ssed -i.DELETEME "s/your/script/" *.txt del *.DELETEME It's a workaround. -- Eric Pement -- Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/sed-users/ <*> To unsubscribe from this group, send an email to: sed-users-unsubscribe@xxxxxxxxxxxxxxx <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by