Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replacing a range of characters in Unix

Status
Not open for further replies.

RJSHA1

Programmer
Apr 12, 2001
66
0
0
GB
Hi there,
I have a to write a script where if data in a file is not one of the following types of data e.g. 0-9 or A..Z or a..z or $,^& then I replace it with spaces. I know that SED is probably the best way to do it, but I'm struggling wit the syntax can any one help please

Ta
Bob...
 
man tr

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Sorry PHV
Can I do someting like this
tr -d ![A..Z] [a..z] [0..9] [%^] filename > filename2

I want all the characters that are not in the ranges above to be replaced eith spaces
 
Sorry PHV
Can I do someting like this
tr -d ![A..Z] [a..z] [0..9] [%^] filename > filename2

I want all the characters that are not in the ranges above to be replaced with spaces
 
Try something like this:
tr -cs '\n0-9_$%^A-Za-z' "[ *]" <filename >filename2

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top