Issue with CD to a hidden dir

I have written a script to secure delete all files in a quarantine folder and my Trash folder. All the commands run trough Terminal via the script.
The problem I am having is when I am changing the directory to the hidden Trash folder. When I do

cd /Users/WatsonN/.Trash

all it does is take it to the /Users/WatsonN folder instead. The problem with this is that the next command is

srm -rfdv *

, so it starts with /Users/WatsonN/Desktop and works its way down. Luckily i caught it before it destroyed anything important.

here is the entire script:

#! /bin/sh
# 
# Nathan Watson
# Nathan@WatsonN.com
#
clear
#Logo
cat /art.txt
#END Logo
#echo Let's start this bad boy on up!!
echo Movin' it on over to Quarantine
cd /Users/WatsonN/Desktop/Quarantine
echo CHModdin them files...
chmod +rw *
echo Here we go.............
srm -rfv *
echo DONE!!!!! YAY!!!!!!!!!!
#
#
echo Now lets tear up that trash can!
echo Lookie here the trash bin....
cd /Users/WatsonN/.Trash
echo Gittin' that trash out of my trailer..... 
srm -rfdv *
echo There ain't no trash in my trailer no more.....

echo CHECK FILES ARE GONE...
cd /Users/WatsonN/Desktop/Quarantine  #LINE 28
echo LISTING........
echo .....Quarantine.....
ls -a
#
echo .....Trash.....
cd /Users/WatsonN/.Trash
ls -a
echo DONE

another issue is this

Line 42 is the line after everything that is after

echo DONE

Thank you so much in advanced :slight_smile:

Try to escape the single quotes in the echo arguments:

echo Gittin\' that trash out of my trailer..... 
echo There ain\'t no trash in my trailer no more.....

You should check the exit status of the cd command:

cd /Users/WatsonN/.Trash || {
  printf 'Error accessing %s\n' '/Users/WatsonN/.Trash'
  exit 1
  }
1 Like

Thank you so much :slight_smile:
It was the single quotes. I ALWAYS forget some little detail. What can I say Its not my job, I dont have to know it :smiley:

Thank you