views:

238

answers:

2

I'm working on a project where we are dealing with importing/exporting data from database tables using ksh scripts and Perl scripts. We have an existing process to export data from a table to a file and it is then imported into another system.

Here's the catch - the export process dumps out pipe delimited files while the system that is doing the import expects files delimited by the ASCII group separator character which is decimal 29, hexidecimal 1d, or octal 35. It shows up in vi as ^] Right now, I'm converting the delimiter via a Perl script. What I'd like to do is tell our export process to just use the delimiter we are expecting. Something like:

export_table.ksh -d '\035'

The problem is I can't figure out how to pass this character to the export script.

I've tried all kinds of combinations of single quotes, double quotes, backslashes, and the octal and hex version of this character.

I'm on Solaris 10 using ksh and/or Perl.

+1  A: 

have you tried:

$'\x29'

actually try this for ]:

echo $'\x5d'

and for ^

echo $'\x5e'

so you just need to do:

export_table.ksh -d $'\x5e\x5d'
ennuikiller
Sorry I wasn't clear enough in my question. I have updated my example of what I'd like to have working. I do NOT want ^] as my delimiter. That is simply what vi displays if I open one of the files in the expected format.I want the group separator ASCII character which is ASCII code 29 or hex 1D. I'll try out what you are suggesting and let you know if it works with that.
Kenny Drobnack
echo $'\x1d' seems to do the trick. Thanks!
Kenny Drobnack
A: 

In bash(1), one can prefix a character with ^v to enter that character verbatim. Perhaps ksh(1) does the same?

Steve Emmerson
This works, but I need to be able to do it from a script, not just interactively. ennuikiller's answer works slightly better for that reason.
Kenny Drobnack