Script to remove characters in text file
Hello all. I need to write a script that will open a text file and find a list of characters strings such as &37, &55 and remove them.
So if there was a line as follows: This is &37 a &55 quick example I want it to rewrite the file so that it now reads: This is a quick example. If it was just the two characters I needed to remove then I would just use a find/replace on Nano or similar, however there are about 60 of these special characters and a script would be much faster. Many thanks for any help. Regards Tim |
|
Vim could easily do the same, but sed would the tool of choice at the command line.
|
additionally sed and vim understand the same command.
|
Quote:
Cheers Tim |
If they are truly 'special characters' like \n and \r or some HEX or OCTAL or UNICODE characters, then you might save time using 'tr' to transform and replace them.
http://www.linfo.org/tr.html https://linux.die.net/man/1/tr |
All times are GMT -5. The time now is 04:13 PM. |