小编Phi*_*ton的帖子

使用反引号时如何在KornShell脚本中保留空格?

我正在使用KornShell(ksh)中的脚本.我的数据库连接是通过SQLPLUS连接到Oracle 9i数据库.我没有任何问题将DB值转换为shell变量,除了任何连续的空格被自动截断为只有一个字符.

这是我的代码示例:

MY_VAR=`sqlplus -s usr/pass@db << !
set heading off;
set pagesize 0;

select a_value from a_table where an_index = 25;
!`
Run Code Online (Sandbox Code Playgroud)

数据库中的实际数据如下:

Dec 15 09:19:10 <24:0070> User record (5    XATY       41839FG8   58775HK9AFF) is invalid for this condition
Run Code Online (Sandbox Code Playgroud)

我上面的代码示例返回如下:

Dec 15 09:19:10 <24:0070> User record (5 XATY 41839FG8 58775HK9AFF) is invalid for this condition
Run Code Online (Sandbox Code Playgroud)

间距对我正在使用的内容至关重要.

预先感谢您的帮助.

unix shell scripting ksh sqlplus

3
推荐指数
1
解决办法
1626
查看次数

标签 统计

ksh ×1

scripting ×1

shell ×1

sqlplus ×1

unix ×1