The test.sh : #!/bin/bash echo $1 if [ $1 == "" ];then echo $1 is null return; fi mkdir $1 test_count=0 while [ 1 ] do test_count=$(( test_count + 1 )) touch $1/$test_count echo $1/$test_count if [ $test_count -eq 5000 ]; then return; fi done ############################### we can run it: ./test.sh /mnt/yaffs2/testdir and then cd /mnt/yaffs2 rm -rf testdir rm: can't remove 'testdir': Directory not empty