Re: removing rogue characters with sed



On 2007-05-27, waffle.horn@xxxxxxxxxxxxxx wrote:
Hi all,

Im trying to remove two types of rogue characters but I can't seem to
think of the correct solution with sed. The characters Im trying to
remove are the @ and ` characters shown below

-0.1000@xxxxxxx

-0.1000`-0.1000

I have tried...

sed 's/@/ /' FILENAME | sed 's/`/ /'

It doesn't seem to work for all instances.

Presumably, those instances are where there's more than one such
character on a line. For that you need to use global substitution
(and you can do it with a single call to sed):

sed -e 's/@/ /g' -e 's/`/ /g' FILENAME

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
.



Relevant Pages

  • Re: removing rogue characters with sed
    ... Im trying to remove two types of rogue characters but I can't seem to ... think of the correct solution with sed. ... replace the command to sed ...
    (comp.unix.shell)
  • Re: removing rogue characters with sed
    ... Im trying to remove two types of rogue characters but I can't seem to ... think of the correct solution with sed. ... certain sorts of tools at low cost and in short order. ...
    (comp.unix.shell)
  • Re: Help: Remove Null from SQL Results
    ... The query displays all 78000 rows, ... >need it to display about 2000 rows. ... >function to only return the first 9 characters. ... as proposed by Michael is the correct solution. ...
    (microsoft.public.sqlserver.programming)
  • Re: printf() and character arrays
    ... > * unless you typed in too many characters to fit in the array). ... It would be easier, or at least shorter, to provide a correct solution ...
    (comp.lang.c)
  • Re: removing rogue characters with sed
    ... Thank you both examples seemed to do the trick. ... appreciated as are the explanations. ... think of the correct solution with sed. ... The characters Im trying to ...
    (comp.unix.shell)