I am trying to replace \t \r and \n with single space from a string like this in bash
message="${message//[$'\t\r\n']/ }"
But this step is taking too much time. These are my observations wc on message
1. "$message" | wc gives
46 116 2518
time taken: 2.513635815s
2. "$message" | wc
85 232 5029
time taken: 14.649522474s
For larger strings, time increases rapidly.
Note: In message variable, I have random english characters only.
What is the reason for this ? How can I make it quicker?