Re: Regarding command Uses

Bob Proulx <[email protected]>
Newsgroups gmane.comp.gnu.utils.bugs
Message-ID <[email protected]>
Gourav Khira wrote:
> Actually, i want to replace any word with another.i used "sed" command but
> it's not getting properly result.
> ...
> If,I want to replace here "this" with "that" using "sed" command.
> 
> sed this that | filename

The sed manual has an entire section on substituting this for that in
section "3.5 The 's' Command".  If sed is installed properly it will
include the documentation.  You can read the documentation that is
installed with sed and therefore will be the matching version like
this:

  info sed

Also the documentation for the most current release is available
online.  The particular section I am referring to is here:

  http://www.gnu.org/software/sed/manual/html_node/The-_0022s_0022-Command.html#The-_0022s_0022-Command

As a direct hint you need to do something like this:

  sed s/this/that/g filename

If the patterns include any character that is special to the shell
then it will need to be quoted.  The prefered Unix/GNU quoting style
is typically the single quote so that all (actually most) characters
are preserved verbatim.  Ports to other operating systems may need
other quoting specific to that port.

  sed 's/this spaced word/that spaced word/g' filename

Bob
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.