-   Linux - Newbie (
-   -   How to delete a directory in /tmp directory (

pradeepdee6 12-14-2012 03:12 AM

How to delete a directory in /tmp directory
Hi Everyone,

Im creating a directory in /tmp location for temporary storage of files. then i move them to actual folder.

Im not able to delete the directory.
Server Version: AIX dseax203 3 5 00CF1AEC4C00
shell : Bash




mkdir /tmp/get.$$.Temp
cd /tmp/get.$$.Temp

ftp -n -vi > FTP_LOG.txt
open dseax203
user User Pass
cd mft_test
get abc*

chmod 777 abc*
mv /tmp/get.$$.Temp/* $FILEDIR
rm -f /tmp/get.$$.Temp
Please help me how can i delete the directory in /tmp directory.

Thanks in Advance.

colucix 12-14-2012 03:42 AM

You missed the -r (recursion) option of rm, necessary to remove directories. If the directory is empty the rmdir command is enough, otherwise rm -r is mandatory.

pradeepdee6 12-14-2012 04:11 AM

Hi colucix,

Thankyou very much for the reply.

I tried with rm -r, rm -rf. But the result was same, im not able to delete the directory.
Since im moving all the files and the directory will be empty, even then rmdir is not able to deleted teh directory.

when i manually use th ecommand in comand prompt, the directory gets deleted.
But when the same command included in shell script, it ll not be able to delete.

Thanks in Advance

colucix 12-14-2012 04:17 AM

Any error message from the script? What if you change #!/usr/bin/ksh with #!/usr/bin/bash or the exact path to the bash shell, if different?

pradeepdee6 12-14-2012 04:32 AM

Hi colucix,
This is the error message.

rm: 0653-610 Cannot remove current directory /tmp/get.15097918.Temp.
#!/usr/bin/bash made no difference.

does /tmp has any special permissions that doesnot allow deleting a directory in it ??

colucix 12-14-2012 04:37 AM

I didn't notice it before, but most likely you have to go out of the directory before removing it.

TobiSGD 12-14-2012 04:40 AM

You can't delete the directory when it is your current working directory. Insert a

cd -
before the rm command to change the current working directory back to the previous state before removing that directory.

pradeepdee6 12-14-2012 04:41 AM

Thanks you so much Hi colucix.


but most likely you have to go out of the directory before removing it.
This was the main reason for my error.


All times are GMT -5. The time now is 12:53 AM.