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!

How to remove slashes in a string

Status
Not open for further replies.

johandepauw

IS-IT--Management
Nov 7, 2008
3
BE
How can I remove all slashes within a string ?

For example :
1/23456/78/999 needs to become
12345678999



 
To be more precise, I have a field called aanvr_arts_rizivnr within my script. It's my aim to alter the contents of aanvr_arts_rizivnr, so that all slashes within this field are removed. And then I want to write the altered contents to an output file called outfileadr.

I've tried it as follows, but this doesn't give the expected result :

aanvr_arts_rizivnr = gsub(/\//,"",aanvr_arts_rizivnr)
print aanvr_arts_rizivnr >> outfileadr

What am I doing wrong ? I'm new to akw, so excuse me if my question appears to be silly.
 
Hi

I have no idea what you want to do there.
Code:
[blue]master #[/blue] cat inputfile 
1/23456/78/999

[blue]master #[/blue] awk '{gsub(/\//,"")}1' inputfile > outputfile

[blue]master #[/blue] cat outputfile 
12345678999

Feherke.
 
Replace this:
aanvr_arts_rizivnr = gsub(/\//,"",aanvr_arts_rizivnr)
print aanvr_arts_rizivnr >> outfileadr
with this:
gsub(/\//,"",aanvr_arts_rizivnr)
print aanvr_arts_rizivnr >> "outfileadr"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
gsub(/\//,"",aanvr_arts_rizivnr)
print aanvr_arts_rizivnr >> outfileadr

Like this, it works !

Thanks for your help.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top