jonnyd
1
Hi all,
Can anyone suggest a way to get a portion of string from the end?
So:
$ORACLE_SID=blt10cr1
We can drop the final '1' and end up with:
$ORACLE_SID=blt10cr
So far I have the following:
echo $ORACLE_SID | cut -c1-5
and
echo $ORACLE_SID | cut -c1-6 | rev
any ideas?
Thanks in advance.
jd
$ echo $ORACLE_SID | sed 's/.$//'
blt10cr
sea
3
If its bash:
echo "${ORACLE_SID:0:${#ORACLE_SID}-1}"
hth
RudiC
4
Try also
echo "${ORACLE_SID%?}"
blt10cr
jonnyd
5
thank guys that works.
echo "${ORACLE_SID%?}"
blt10cr
nice and simple