Afficher un message
Vieux 27/05/2007, 20h17   #3
Andrew Smallshaw
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: removing rogue characters with sed

On 2007-05-27, waffle.horn@googlemail.com <waffle.horn@googlemail.com> 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@-0.1000
>
> -0.1000`-0.1000
>
> I have tried...
>
> sed 's/@/ /' FILENAME | sed 's/`/ /'


You probably weant the 'g' option to s to make the replacements
global. Without it sed will only replace the first occurance.

You also don't need to call sed twice like this. You can feed sed
more than one command at a time, or in this instance combine the
commands into one:

sed 's/[@`]/ /g' FILENAME

That will replace either a "@" or "`" with spaces like your example
above did. To actually delete them, replace the command to sed
with 's/[@`]//g'

--
Andrew Smallshaw
andrews@sdf.lonestar.org
  Réponse avec citation
 
Page generated in 0,04782 seconds with 9 queries