Re: sed substitution that contains forward slash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2009-03-31 at 14:11 -1000, David Burns wrote:
> On Tue, Mar 31, 2009 at 1:37 PM, Craig White <craigwhite@xxxxxxxxxxx> wrote:
> > subtitle...fun with sed
> >
> > I have a list of changes to make to a file...
> >
> > dc              rc
> > -------------   -------
> > 15T6145V        DELETED
> > NATL19502       DELETED
> > Q10MR11/FL12V   DELETED
> > Q1500T3/CL120   DELETED
> >
> > and things work until I get to the 3rd item which has a forward slash
> > and it fails to substitute with commands like below...
> >
> > sed -i "s%${dc}%${rc}%g" ARsalesorderdetails.csv
> > and
> > sed -i "s/${dc}/${rc}/g" ARsalesorderdetails.csv
> >
> > The latter producing error on screen...
> > sed: -e expression #1, char 17: unknown option to `s'
> >
> > While the former simply doesn't complain but doesn't make the change
> > either.
> >
> > Is there a way to coerce sed to identify & replace strings with a /
> > inside?
> >
> 
> I don't think it is sed that is giving you a problem:
> 
> $ echo "Q10MR11/FL12V "|sed "s|Q10MR11/FL12V|DELETED|"
> DELETED
> 
> Perhaps bash is not resolving your use of the ${dc} and ${rc}
> variables as you expect. Since you do not include the full string of
> commands and I never use ${}, I don't know what the problem is.
> Dave
----
you could be right...my problem is I can't enclose the sed string in
single quotes because the variables won't expand and I find that just
doing this...

sed -i "s|$dc|$rc|g" ARsalesorderdetails.csv

fails and still leaves me with this...

1,6066,"Q1500T3/CL/120V",2," 6.99 ",2,,,"2007-01-09",1,,,

so I'm strugging with various ways...

sed -i "s|$(dc)|$(rc)|g" ARsalesorderdetails.csv # doesn't work
or the curly braces to try to keep the string together

Craig


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux