how to remove all .Rhistory file?

remove all .Rhistory file from my computer

As this involves 'unlink' to delete data from a device, use with extreme caution / at your own risk. i.e. the last line modifies your computer.

exact_file_name <- ".Rhistory"

library(shinyFiles)
library(purrr)
library(glue)

(drives <- getVolumes()())
## drives <-getwd() # if you dont need over every drive but from some base path like a working directory you can do this instead
(list_of_files_to_delete <- map(drives,
    ~{      file.path(.x,list.files(path = .x,
                 pattern = glue("^{exact_file_name}$"),
                 recursive = TRUE,all.files = TRUE))
    }) %>% unlist())

 walk(list_of_files_to_delete,unlink)