Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Plus sign replacement

Status
Not open for further replies.

ediman4902

Programmer
Jun 19, 2007
6
US
I'm trying to substitute a plus sign (+) with another character but I can't seem to get it to work using GSUB. I am using the AWK95 version of AWK......thank you
 
Use \+

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I put this into my program but it gives me an error:

gsub(\+, " ", rectyp)
and also tried
gsub("\+", " ", rectyp)

All I'm trying to do is replace the plus sign with a space
 
I don't know awk95, but with a posix compliant awk flavor, the following should work:
gsub(/\+/, " ", rectyp)

BTW, but it gives me an error is not very informative, so, WHICH ERROR MESSAGE ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi

PHV, your code works in [tt]awk95[/tt] too :
Code:
[blue]master #[/blue] /cygdrive/f/Program\ Files/awk95.exe 'BEGIN{rectyp="*+-/";gsub(/\+/," ",rectyp);print rectyp}'
* -/
Code parameter kindly passed to [tt]awk95[/tt] by CygWin.

Feherke.
 
Thank you all for the updates - it works to use the following in AWK95:

gsub(/\+/, " ", rectyp)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top