Operating System - HP-UX
1830165 Members
5930 Online
109999 Solutions
New Discussion

Script to find files with spaces

 
SOLVED
Go to solution
Nobody's Hero
Valued Contributor

Script to find files with spaces

Is there a simple script that can search a filesystem and compile a lit of files that contain spaces? I cant think of a way to do that seeing the unix will stop at the first white space within the filename.

UNIX IS GOOD
4 REPLIES 4
James R. Ferguson
Acclaimed Contributor
Solution

Re: Script to find files with spaces

Hi:

You could do:

# cd /path
# find . -type f -name "* *"

Regards!

...JRF...
Nobody's Hero
Valued Contributor

Re: Script to find files with spaces

James, Ok, im feeling inadequate here. That was easy.

How does the find command see "* *" as a file name containing spaces?

How did this work?
UNIX IS GOOD
James R. Ferguson
Acclaimed Contributor

Re: Script to find files with spaces

Hi (again):

We quote the string to prevent the shell from expanding the wildcard.

The "* *" says return matches for zero or more characters ('*'), a space, and zero or more characters again. This finds file names of only spaces; file names with leading or trailing spaces; or file names with embedded spaces.

Regards!

...JRF...
Sundar G
Frequent Advisor

Re: Script to find files with spaces

Hi,
That find command will work. Anything else you expect from the script?