Bash Find All File Names With White Spaces

Posted on in Categories , , , , , , , , , last updated August 14, 2009

How do I find all files with one ore more blank space (while spaces) in their name under UNIX like operating systems?

Simple use ls command along with egrep to list only file names with white spaces

ls | egrep '. '

Sample Outputs:

Find the memory used by a program.doc
Keep moving forward.doc

You can copy all such files to other directories using xargs:

ls  | egrep '. ' | xargs -I{} cp -v {} /tmp/

2 comment

Leave a Comment