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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem using gsub() on a field containing "*" char

Status
Not open for further replies.

xuenylom

Programmer
Aug 24, 2004
7
FR
hi,

I am running a script on a file that contains line with fields containing the "*" character.

example:

----------------------------------------------
ORG A* U 994825555 DS
----------------------------------------------

first field stops after the *.
What I need to do is put this line in the file org.txt

i'm using the gsub function as follows:

------------------------
nfic=$1gsub(" A*","",nfic)
line=$0
fic_algo=nfic".txt"
print line>>fic_algo
------------------------

now, when I run the script, I get "can't open ORG*.txt"

I can't find why this doesn't work

thank you for your help
 
Try a backslash before the *

nfic=$1
gsub(/ A\*/,"",nfic)

CaKiwi
 
Something like this ?
nfic=$1;gsub(/ A\*/,"",nfic)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
nope, I still got the same error, and I don't know where to look in the AWK manual to find why i get this error.

 
works fine with Solaris' nawk - no escapes needed.
creates a file 'A*.txt'.

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
ok, so get rid ot it!

gsub("[*]","",nfic);

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top