[Discuss] sed question

Noel Burton-Krahn noel at burton-krahn.com
Wed May 21 10:44:27 PDT 2008


This will delete all non-word (alphanumeric plus "_") characters from
a file named filename, and save a copy of the original file as
filename.bak

perl -pni.bak -e 's/[^\w]//gi' filename

You may want to use "[:print:]" instead of "\w" above to match all
printable characters.

~Noel


On 5/21/08, pw <p.willis at telus.net> wrote:
> Hello,
>
> Is there a way to use sed to remove all non-alphanumeric
> characters from a file.
>
> ie:
>
> sed -e "s/![a-zA-Z]&![0-9]/\ /g"
>
>
> Peter
> _______________________________________________
> Discuss mailing list
> Discuss at vlug.org
> http://ladybug.vlug.org/cgi-bin/mailman/listinfo/discuss
>


More information about the Discuss mailing list