That's brilliant! It works.
I like how efficient your suggestion is. I guess you must be writing awk code more than 2-3 lines every 2 years :-)
Thanks again!
nnxx
Hi PH,
Thanks for your suggestions. I don't know if its my gawk version (3.1.1), but neither approach is working for me. Anyway, I'll spend some more time debugging this.
Thanks again.
Nitin.
Hi PHV,
Thanks for the quick response. My usage is pretty simple, maybe too simple. I have the following in a text file and I simply run it from cmd line...
gawk '{if(substr($0,1,1)=="c") {gsub(/out/, "\'", $0); print $0;} else print }' infile > outfile
How can -f help ?
Thanks!
nnxx
Hello experts,
Any idea how to substitute a character with a single quote "'" in awk ?
If I use gsub, for example ..
gsub(/out/, "in", $0)
this replaces "out" with "in". But if I want to replace "out" with "'" instead, it obviously gives an error since it thinks its EOF.
I've tried...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.