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

Re: bash quoting problems



On 2011-08-10 07:46, Ivan Shmakov wrote:
Andreas Berglund<andreas.berglund@home.se>  writes:

  >  I have a problem with the following sed snippet

  >  sed -i s"|^\( *PATH="\)\(.*\)|\1$ADD:\2|" ~/profile-test

  >  I need soft quotes in order for $ADD to expand and I also need to
  >  math against one doublequote in the regexp in for $ADD to be put in
  >  the corrct place.

	The double quote character within Shell's double quotes can be
	escaped with a backslash (“\”):

    sed -i "s|^\( *PATH=\"\)\(.*\)|\1${ADD}:\2|"

	However, one is by no means forced to use just one kind of
	quotes in Shell, so the following is also possible:

    sed -i 's|^\( *PATH="\)\(.*\)|\1'"${ADD}"':\2|'

  >  Does anyone know how to do this?

	The questions like this are much more likely to be answered by
	the comp.unix.shell Usenet newsgroup folks.  The newsgroup could
	be accessed either using some sort of newsreader software (Gnus,
	Alpine, SLRN, Icedove/Thunderbird, etc.), e. g.:

Thanks I'll make sure to gain access to that


news:comp.unix.shell
nntp://aioe.org/comp.unix.shell/

	Or with a Web browser, e. g.:

http://www.webuse.net/frameset.php?ng=comp.unix.shell
http://groups.google.com/group/comp.unix.shell



Reply to: