-1

以下に、X個の出力を持つスクリプトを示します。

#!/bin/bash

instant_client="/root/ora_client/instantclient_11_2"
output=`$instant_client/sqlplus -s HRUSER/HRUSER@TOMLWF <<EOF
set heading off
set feedback off
set lines 10000
set pagesize 10000
select count (1) from onboardingcandidates o, candidatedetails c where o.candidateid=c.candidateid and     o.JOININGSTATUS='0091' and to_date(o.joiningdate)=to_date(sysdate+5);

EOF

exit`

echo $output

Output:
cand1
cand2
cand3
cand62

必要な出力:

cand1, cand2, cand3, cand62
4

2 に答える 2

1

スペースが必要ない場合:

... | paste -d, -s -

スペースが必要な場合:

... | paste -d, -s - | sed 's/,/, /g'
于 2012-11-01T19:08:08.053 に答える
0

awkを使用してORSを変更します。

echo $output | awk -v ORS=", "  '{print $0}'
于 2012-11-01T19:08:36.237 に答える