bash - What are some good ways to delete files with blank(invisible) names? -


i discovered files blank names in code repository, don't know how find them , delete them.

assuming have access find command,

find . -regex ".*\/[[:space:]][[:space:]]*" -exec rm {} \; 

if you'd check before deleting,

$ mkdir -p c/d # make empty filenames $ touch " " " b" "a b" $ touch "c/ " "c/ b" "c/a b" $ touch "c/d/ " $ touch "c/d/  " # echo filenames markings $ find . -regex ".*\/[[:space:]][[:space:]]*" -exec echo '{}<blank' \; ./ <blank ./c/ <blank ./c/d/ <blank ./c/d/  <blank 

note: surprise, works full-width spaces.


Comments