Entering edit mode
4.6 years ago
sor.draga
•
0
Hello, guys!
I've used awk in the past for large file manipulation and substitutions.Recently, I've used it to substitute, for ex letter A with a set of characters:
$ awk '{gsub(/A/,"@@@")}1' in.txt >> out.txt
where in.txt
contains strings of letters of various length. (AAA
, BBB
, CCC
, ABABAB
etc)
How can I use gsub
to replace all characters A
in my file with @@@
, B
with ###
, C
with %%%
etc
I am guessing it should be something close to:
$ awk '{gsub(/A|B|C/,"&123")}1' in.txt > out.txt
Many thanks!
and as @ATpoint mentioned: