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

AWK Script problem converting number to string

Status
Not open for further replies.
Dec 8, 2003
17,047
GB
Hi...

I'm not sure if this is the right forum (is AWK related to AWK Script?)...

We currently use CVS for our version control, and are looking to migrate to PVCS.

In CVS, our "author" field is numerical, normally 6 digits (for example, 865978, 832703, etc).

It appears that the CVS -> PVCS conversion script we are using (written in AWK Script) fell over on that, seemingly unable to handle the fact that what it was expecting (alphanumeric) was numeric only.

Does anyone have any idea about converting a number to a string in AWK Script? We don't need to do any special processing... Just get the string representation of a number.

I have 0 idea about AWK Script, so don't even know if it a typed or untyped language.

Thanks in advance for any help!

Dan
 
show us the portiion of your awk script that proceed the author field.

By defaut, if a variable contains "000123" awk print it as "123".
You can do something like this :

author="012345"
printf("Author: %06d\n",author);

Jean Pierre.
 
To force an awk variable or field to string, simply concatenate an empty string to it, like this:
echo "123456789012345" | awk '{print $1+0,$1""}'
Or use %s in a sprintf or printf call.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top