How to replace dot or any character with AWK
Code:
echo 'This is a sentence. This is another sentence.' | awk '{gsub(/\./,"",$0);print $0}'
This is a sentence This is another sentence
Few notes:
- "gsub" is a string subroutine in awk. It requires at least three parameters: 1: the regular expression match, 2: the substitution and 3: the target string that is subject for substitution
- the substitution requires double quotes.
Below I'm replacing the "dot" character and also omitting the new line:
Code:
# echo 'This is a sentence. This is another sentence.' | awk '{gsub(/\./,"",$0);printf $0}'
This is a sentence This is another sentence