I am writing a Ruby script inside which I would like to invoke/execute some shell commands.
The shell commands I would like to run should check if a directory named 'tmp' under
/var/lib/mysql/ exists or not.
if it exists, remove all the files (including sub-dirs & files) inside
If it does not exist, just create it.
(P.S. only root user can access
mkdir will create directory, but I am not sure how to make a command to check if the directory exists or not.
As a whole, I would like to have some shell commands to achieve the scenario described above, and the more elegant way the better, as I will run the shell commands in a ruby script.
Anyone can Help me ?