Operating System - HP-UX
1847047 Members
5171 Online
110261 Solutions
New Discussion

Re: No carriage return using temp parameter

 
SOLVED
Go to solution
yc_2
Regular Advisor

No carriage return using temp parameter

Hi,

Don't understand why there is no carriage return for the temp parameter set in a script. Below is the example:

#!/usr/bin/sh
V_TEMPDIR=/usr/local/etc
V_PRTDIR=`ll $V_TEMPDIR`
print $V_PRTDIR

Any pointer or work around is appreciated.


Rgds,
YC
1 REPLY 1
Mark Grant
Honored Contributor
Solution

Re: No carriage return using temp parameter

Everybody has found this out at some time.

It is because of your shell's $IFS variable. This is the internal field seperator for the shell which by default includes a carriage return. In other words, the shell sees the carriage return as a seperator between "tokens" or words. The solution goes soemthing like this

#!/usr/bin/sh

V_TEMPDIR=/usr/local/etc

TMPIFS=$IFS
IFS=" "

V_PRTDIR=`ll $V_TEMPDIR`
print $V_PRTDIR

IFS=$TMPIFS
Never preceed any demonstration with anything more predictive than "watch this"