Question: I am trying to find and delete all `.swp` files in my current directory. I was using below command:

```
rm -i `find . | grep .swp$`

```

But everytime it is giving me this error:

```
rm: missing operand
Try `rm --help' for more information.

```

Anything wrong I am doing?

Answer: 
The error message you received probably indicates that no file matched the name pattern `.swp$`. A generally safer way to do what you wrote (because it will handle any file name):

```
find . -name '*.swp' -print0 | xargs -0 rm -i --

```

In the snippet above, I used `-print0` so that `find` separates
records with null characters; the default is newlines, which
unfortunately is valid within a filename. With `-print0`, the command
works works with any filenames, including any that embed
newlines. Likewise, `xargs -0` processes its input as null-separated
records.
Sometimes swap files don't have `.swp` extension only. It may have `saw`, `swb`, `swp`, etc extensions as well.

```
sushil@batpod:/app/DDB# ls -a
.gui.py.swo
gui.py
.serializers.py.swp
serializers.py
.tcinfo.py.swm
tcinfo.py
.views.py.swb
views.py

```

and so on...

I have created one command which deletes almost all swap files with extension `sw*`

Command:

```
find . -name '*.sw\*' | xargs -i rm {}

```

***NOTE***: Before executing above command first have a look at the files command is going to delete, using

```
find . -name '*.sw\*'

```

Hope you don't delete some important files.