Skip to content

Delete files with space characters in file name

Introduction

If you have ever tried to delete a file with a space character in its name in Linux, you may have encountered an error message. This is because the space character is interpreted as a separator between the file name and its extension. In this blog post, we will show you how to delete files with space characters in their names in Linux.

rm 'my file.txt'

or

rm my\\ file.txt

Both of these commands will remove the file from your system.

Using find

In this case, you can use find command to delete files with space in file name.

find . -name "* *" -type f -delete

Using Wildcards to Delete Files with Space Characters

rm file*spaces.txt
Feedback