Skip to main content
added 1 character in body
Source Link

There is a simpler way - use (any) shell word splitting.

Let's create a script like that:

#!/bin/bash
readonly CONN="${RDS_ADMIN}@//${RDS_HOST}/${RDS_DBNAME}"

SCN=$(sqlplus -S $CONN << EOF
SET HEADING OFF
SELECT CURRENT_SCN FROM V\$DATABASE;
EOF
)

echo ">>>$SCN<<<"
SCN=$(echo $SCN)
echo ">>>$SCN<<<"

Here is the output of the script:

oracle@ctrl-dev|265$ ./t.sh
>>>
   87401840<<<
>>>87401840<<<
oracle@ctrl-dev|266$ 

There is no external command required, the downside is VAR=$(echo $VAR) construction which does not look nice.

There is a simpler way - use (any) shell word splitting.

Let's create a script like that:

#!/bin/bash
readonly CONN="${RDS_ADMIN}@//${RDS_HOST/${RDS_DBNAME}"

SCN=$(sqlplus -S $CONN << EOF
SET HEADING OFF
SELECT CURRENT_SCN FROM V\$DATABASE;
EOF
)

echo ">>>$SCN<<<"
SCN=$(echo $SCN)
echo ">>>$SCN<<<"

Here is the output of the script:

oracle@ctrl-dev|265$ ./t.sh
>>>
   87401840<<<
>>>87401840<<<
oracle@ctrl-dev|266$ 

There is no external command required, the downside is VAR=$(echo $VAR) construction which does not look nice.

There is a simpler way - use (any) shell word splitting.

Let's create a script like that:

#!/bin/bash
readonly CONN="${RDS_ADMIN}@//${RDS_HOST}/${RDS_DBNAME}"

SCN=$(sqlplus -S $CONN << EOF
SET HEADING OFF
SELECT CURRENT_SCN FROM V\$DATABASE;
EOF
)

echo ">>>$SCN<<<"
SCN=$(echo $SCN)
echo ">>>$SCN<<<"

Here is the output of the script:

oracle@ctrl-dev|265$ ./t.sh
>>>
   87401840<<<
>>>87401840<<<
oracle@ctrl-dev|266$ 

There is no external command required, the downside is VAR=$(echo $VAR) construction which does not look nice.

added 6 characters in body
Source Link

There is a simpler way - use (any) shell word splitting.

Let's create a script like that:

#!/bin/bash
readonly CONN="${RDS_ADMIN}@//${RDS_HOST/${RDS_DBNAME}"

SCN=$(sqlplus -S $CONN << EOF
SET HEADING OFF
SELECT CURRENT_SCN FROM V\$DATABASE;
EOF
)

echo ">>>$SCN<<<"
SCN=$(echo $SCN)
echo ">>>$SCN<<<"

Here is the output of the script:

oracle@ctrl-dev|265$ ./t.sh
>>>
   87401840<<<
>>>87401840<<<
oracle@ctrl-dev|266$ 

There is no external command required, the downside is VAR=$(echo $VAR) construction which does not look nice.

There is a simpler way - use shell word splitting.

Let's create a script like that:

#!/bin/bash
readonly CONN="${RDS_ADMIN}@//${RDS_HOST/${RDS_DBNAME}"

SCN=$(sqlplus -S $CONN << EOF
SET HEADING OFF
SELECT CURRENT_SCN FROM V\$DATABASE;
EOF
)

echo ">>>$SCN<<<"
SCN=$(echo $SCN)
echo ">>>$SCN<<<"

Here is the output of the script:

oracle@ctrl-dev|265$ ./t.sh
>>>
   87401840<<<
>>>87401840<<<
oracle@ctrl-dev|266$ 

There is no external command required, the downside is VAR=$(echo $VAR) construction which does not look nice.

There is a simpler way - use (any) shell word splitting.

Let's create a script like that:

#!/bin/bash
readonly CONN="${RDS_ADMIN}@//${RDS_HOST/${RDS_DBNAME}"

SCN=$(sqlplus -S $CONN << EOF
SET HEADING OFF
SELECT CURRENT_SCN FROM V\$DATABASE;
EOF
)

echo ">>>$SCN<<<"
SCN=$(echo $SCN)
echo ">>>$SCN<<<"

Here is the output of the script:

oracle@ctrl-dev|265$ ./t.sh
>>>
   87401840<<<
>>>87401840<<<
oracle@ctrl-dev|266$ 

There is no external command required, the downside is VAR=$(echo $VAR) construction which does not look nice.

Source Link

There is a simpler way - use shell word splitting.

Let's create a script like that:

#!/bin/bash
readonly CONN="${RDS_ADMIN}@//${RDS_HOST/${RDS_DBNAME}"

SCN=$(sqlplus -S $CONN << EOF
SET HEADING OFF
SELECT CURRENT_SCN FROM V\$DATABASE;
EOF
)

echo ">>>$SCN<<<"
SCN=$(echo $SCN)
echo ">>>$SCN<<<"

Here is the output of the script:

oracle@ctrl-dev|265$ ./t.sh
>>>
   87401840<<<
>>>87401840<<<
oracle@ctrl-dev|266$ 

There is no external command required, the downside is VAR=$(echo $VAR) construction which does not look nice.