Re: Need help with SED

"Daniel" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
Seems quite odd the file name is sedDOSSUX :) Does 
it really say DOS SUX? Someone has a sense of humor!

I don't know if it explains the problem, but it 
makes no sense to use both -i and "> junk.txt".
Use one or the other, but not both.

You had it:

sed -i "s/1.0101/1.0400/g" "%%a" > junk.txt
move junk.txt "%%a"

Instead, use either:

sed -i "s/1.0101/1.0400/g" "%%a"

Or:

sed "s/1.0101/1.0400/g" "%%a" > junk.txt
move junk.txt "%%a"

--- In [email protected], kn srivastava <k-n-s@...> wrote:
>
> GNU sed version 4.1.5
> 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.
> 
> On Sun, Feb 17, 2013 at 8:04 PM, Daniel <dagoldman@...> wrote:
> >
> >
> > What does sed -v or sed --version say?
> > Always helpful to know what version.
> >
> > What is the error message when you don't
> > use -i and use "move junk.txt" instead?
> >
> > s/1\.0101/1.0400/g is safer (very picky).
> >
> > Does it work without the "%%a" syntax?
> > In other words, try a simple case first,
> > to narrow down where the problem is.
> >
> > Daniel
> >
> > --- In [email protected], kn srivastava <k-n-s@> wrote:
> >>
> >> sed: cannot rename ./sedDOSSUX: File exists
> >>
> >> I get the above message.
> >>
> >> Regards
> >> Kailash
> >>
> >> On Fri, Feb 15, 2013 at 5:24 PM, Amarendra Godbole
> >> <Amarendra_Godbole@> wrote:
> >> > I place editing can be problematic which is why classic sed does not touch the original file. This is a gnu extension (a move to make it more user friendly but broken in my opinion). So you should have gnu sed on windows. Secondly make sure the -i switch is not broken for your version. Thirdly tell us what does it complain and maybe I can help further.
> >> >
> >> > -ag
> >> >
> >> > --
> >> > sent via 100% recycled electrons from my mobile command center.
> >> >
> >> > On Feb 15, 2013, at 2:51 AM, "goshainganj" <k-n-s@> wrote:
> >> >
> >> >> @echo off
> >> >> dir /b /s | find ".pscx" > mydir.txt
> >> >> pushd .
> >> >> for /F "delims==" %%a in (mydir.txt) do (
> >> >>    echo "%%a"
> >> >>    sed -i "s/1.0101/1.0400/g" "%%a" > junk.txt
> >> >>    move junk.txt "%%a"
> >> >> )
> >> >> popd
> >> >> del mydir.txt
> >> >> -------------------
> >> >>
> >> >> I wrote the above code to change 1.0101 to 1.0400 in all .pscx files in all directories from where I am executing this batch file.
> >> >>
> >> >> I read SED manual and it said -i option would directly change .pscx files but it complained. So I directed the output to junk.txt. I wanted to move junk.txt back to .pscx file. It is this part of the above script that's not working.
> >> >>
> >> >> Any suggestions why -i is not working and how I can make the above to work?
> >> >>
> >> >> Thanx
> >> >> Kailash
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> ------------------------------------
> >> >>
> >> >> --
> >> >> Yahoo! Groups Links
> >> >>
> >> >>
> >> >>
> >>
> >
> >
> >
> >
> > ------------------------------------
> >
> > --
> > Yahoo! Groups Links
> >
> >
> >
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.