directory change in shell script

Hi,

I am trying to change the directory in my script, & want to check if the directory is present or not .

Ex:
cd /home/xyz/temp/logs

if the logs directory is not present i want to show the error in script instead of shell script error.

Can anybody please help me on the same

Thx in advance

$ [ -d /path/to/dir ] || echo 'Kaboom!!'

I didn't quite understand what do you mean with 'i want to show the error in script'. If you want to print an informative error message to stderr than the following may help

TRG_DIR="/home/xyz/temp/logs"
if test -d "$TRG_DIR"; then
   cd "$TRG_DIR"
else
   echo "$TRG_DIR does not exist" >&2
   exit 1
fi