You may need to to
/bin/echo "Hello${TAB}World"
or
echo -t "Hello${TAB}World"
Main Topics
Browse All TopicsHello All,
I need help in displaying the tab character in UNIX. I am writing a script which will load the tab delimited text file into a Teradata table. I tried to use the below but it didn’t work
TAB= “\t”
echo "Hello${TAB}World"
TAB1='\t'
echo "Hello${TAB1}WORLD"
Both the echo statements displayed the tab in between the string ‘Hello World’. But in the script after connecting to the database the $TAB is displayed as \t. Can anyone help me out on this issue to populate the tab character? Below is the line of code I use in my script to populate the TAB character. If I use a tab like “ “ the script works fine.
SET RECORD VARTEXT "$TAB";
$ echo $SHELL
/usr/bin/sh
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Sorry for not being clear. The echo works fine before connecting to the database. Once I connect to the database it is displayed as /t.
Below is the sample script
USERID=$1
DATABASE=$2
TABLE=$3
DATAFILE=$4
TAB="\t"
LOGON=`cat ${BIN_DIR/USERID}_logon`
fastload << EOF
${LOGON}
DROP TABLE ${DATABASE}.${TABLE}_Err1;
DROP TABLE ${DATABASE}.${TABLE}_Err2;
ERRLIMIT 50;
BEGIN LOADING
${DATABASE}.${TABLE}
ERRORFILES ${DATABASE}.${TABLE}_Err1,
${DATABASE}.${TABLE}_Err2
CHECKPOINT 100000;
SET RECORD VARTEXT "${TAB}";
DEFINE
Col1 (VARCHAR(5))
,col2 (VARCHAR(2))
,col3 (VARCHAR(12))
I get an error on the line SET RECORD VARTEXT "${TAB}"; becuase in the log the value of $TAB shows as \t.
Below is the error
0006 SET RECORD VARTEXT "\t";
**** 17:48:25 Incorrect syntax for delimiter character specification
**** 17:48:25 Command not processed
If I hardcode the tab like SET RECORD VARTEXT " "; then it works but I want to parameterize so that in future I can change to any delimiter I want to.
Thanks
Hi cutie,
I found one reference to this issue, and it seems that "\t" works. But it may require certain conditions that aren't obvious.
http://www.webservertalk.c
http://archives.devshed.co
The links are to the same thread.
Kent
The problem is that you are passing the value of your delimiter to an input (<<) statement, as part of your database statement. The string passed via (<<) is being sent literally, as you have typed it.
So, in your example, the value of "${TAB}" is expanded literally, so that you are actually passing "\t" as the delimiter, and not a tab character as you expect.
You say you would like to do this in case the delimiter changes in a later iteration, which is commendable when you are writing a generic script, but since your script uses 'drop table', which is an aggressive and job-specific task, I wouldn't bother trying to genericise the script, just type the tab in place.
If you really want a generic script, you should at least:
1) Move the database instructions to an external file, passed to the script either as stdin, or as a named file parameter, or as an editable constant like you have with TAB
2) Instead of varying the value you pass to SET RECORD VARTEXT, you should always use the same delimiter, and instead pass the input file through a sed command to bring it into the format required by the script, by replacing the delimiter for that file with the delimiter enforced by the script.
However, if you insist on doing it this way, pretending to have a generic script, you can achieve this in a number of ways:
A) By breaking down the "<<" statement into three steps:
#step 1
fastload << EOT1
${LOGON}
DROP TABLE ${DATABASE}.${TABLE}_Err1;
DROP TABLE ${DATABASE}.${TABLE}_Err2;
ERRLIMIT 50;
BEGIN LOADING
${DATABASE}.${TABLE}
ERRORFILES ${DATABASE}.${TABLE}_Err1,
${DATABASE}.${TABLE}_Err2
CHECKPOINT 100000;
SET RECORD VARTEXT
EOT1
# step 2
fastload << $TAB
# step 3
fastload << EOT2
;
DEFINE
Col1 (VARCHAR(5))
,col2 (VARCHAR(2))
,col3 (VARCHAR(12))
EOT2
B) By removing the quotes. Note that the syntax ${..} implies a quote itself, so you are essentially passing ""\t"". Anyway, just try replacing "${TAB}" with $TAB and see if that works. If it doesn't, you need to split the << input so that the TAB is passed outside of any other string.
Apologize for getting back late.
siliconbrit, Thanks for the detail explanation.
Kdo, Thanks for the search
Ozo, Thanks the TAB=" " worked for me.
Can you please let me know which is the best way to pass a tab in the command line parameter of a script. Ex: in the script TAB=$4 then how can I pass tab to the 4th parameter. Except: " " is there any better way of doing?
Thanks guys for all the help. I will close the question as soon as i get the answer.
When the shell invokes your command, it will expand any tab character as whitespace, unless that whitespace is quoted. Therefore, there is no other way of passing your tab as a command-line parameter unless it is quoted.
Even quoted tabs may not pass correctly depending on your prevailing shell and version of UNIX, although in this instance, you should be safe since you are using the core bourne shell.
However, please let me say again that you are approaching this the wrong way around. You are going to the trouble of creating a 'generic' script, by concerning yourself with the tab character, while the script includes code which is job-specific.
If you genuinely have input files that might be delimited by one of many characters, why dont you make the first job in your script to format the input file into a standard delimited file and *then* pass it to your database job. So, if the file is delimited by spaces, or commas, replace these with tabs into a temporary file, then work with that file instead.
Furthermore, there is probably a limited number of possible delimiters that could be used depending on your data, and there is probably a known architecture to the input file, so for example it may be possible to work out that the delimiter character is always the sixth character in the file.
Business Accounts
Answer for Membership
by: KdoPosted on 2007-02-23 at 12:08:04ID: 18598856
Hi cutie,
Where exactly is the tab displaying as '\t'? Do you know what command or commands are involved?