Reputation: 57
I know that using sed -E 's/[^[:alnum:][:space:]]+/?/g $input'
will replace all non-alphanumeric characters of my input file with question mark.
How am I supposed to do the same thing with AWK?
Upvotes: 1
Views: 1364
Reputation: 133770
You need to fix your regex as well as you need to use awk
's gsub
function for your requirement. since we are mentioning gsub
(global substitution) we need not to use +
here as it will catch everything at once and will replace everything with a single ?
.
awk '{gsub(/[^[:alnum:][:space:]]/,"?")} 1' Input_file
With input Hello!@#$
it will become as Hello????
.
Upvotes: 4