Bash Find All File Names With White Spaces

by on August 14, 2006 · 1 comment· LAST UPDATED August 14, 2009

in , ,

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/
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 1 comment… read it below or add one }

1 Dan Lund June 11, 2013 at 7:16 pm

Thank you, this was very helpful.

Reply

Leave a Comment

Tagged as: , , , , , , , , , ,

Previous Faq:

Next Faq: