Remove all files inside a directory
azzamsa opened this issue · comments
Hi.
I am having a hard time removing all files inside a directory. With bash, I can use rm -rf /home/user/.tmp/*
(note asterisk).
With xshell, it doesn't work.
cmd!(sh, "rm -rf /home/user/.tmp/*").run()?; // ⚠️, doesn't work
sh.remove_path("/home/user/.tmp/*")?; // ⚠️, doesn't work
My only option is to remove the .tmp
directory and recreate it again.
Is there any way to tell xshell to remove the content of a directory, similar to .tmp/*
, leaving the parent directory (.tmp
) intact?
Thanks a lot for xshell
let paths = fs::read_dir("/home/user/.tmp"))?;
for path in paths {
sh.remove_path(path?.path())?;
}
Solved
FWIW, I think it would make sense for xshell to support globbing, but yeah, that’s not impemented