|


| NAVIGATION |
|
Home |
|
Store |
|
|
| INSIDE MAC |
|
Television Shows |
|
Broadcast Shows |
|
Daily News Shows |
|
Special Shows |
|
|
| EVENTS |
|
|
|
|
|
|
|
|
| DAILY TIPS |
|
Design |
|
Mac OS X |
|
Mac OS X UNIX |
|
|
| COMMUNITY |
|
Forums |
|
Surveys |
|
|
| NEWS |
|
Current |
|
Press |
|
Archive |
|
|
| FEATURES |
|
Editorial |
|
Dr. Mac |
|
Reviews |
|
Reader Reports |
|
|
| RESOURCES |
|
FAQ |
|
Documentation |
|
Learning Center |
|
MAN pages |
|
Glossary |
|
Tutorials |
|
Tips |
|
Links |
|
|
|

|
|
|
OSXFAQ Mac OS X UNIX Tip-of-the-Day

Week 98 - Spaces in Filenames (7 February 2005)
by
Adrian Mayo - Editor, OSXFAQ
Tuesday - Find, Xargs, and Spaces
'Find' is a command often used to root out particular files in a directory hierarchy and process each file, often by passing the filenames to 'xargs'.
However, it will fail for filenames with spaces:
$ ls -1 file*
file one
file two
$ find . -name "file*" | xargs ls -l
ls: ./file: No such file or directory
ls: one: No such file or directory
ls: ./file: No such file or directory
ls: two: No such file or directory
Fix this using the '-print0' option of 'find', and the '-0' option of 'xargs'.
$ find . -name "file*" -print0 | xargs -0 ls -l
-rw-r--r-- 1 saruman saruman 0 Feb 7 14:34 ./file one
-rw-r--r-- 1 saruman saruman 0 Feb 7 14:34 ./file two
'-print0' tells 'find' to null-separate filenames when it produces the list of found files, instead of space-separating them. '-0' tells 'xargs' to expect null-separated filenames.
If you want to learn more about Mac OS X Unix visit the Learning Center
click.
- For beginners: Mac OS X Unix Tutorials
- For detailed information on specific topics: Advanced Unix
- For OS X in gereral: Mac OS X Tutorials
|





|
 |
|
 |
Copyright © 2000-2008 Inside Mac Media, Inc. All rights reserved. |
Apple assumes no responsibility with regard to the selection, performance, or use of the products or services. All understandings, agreements, or warranties, if any, take place directly between the vendors and prospective users. |
| Apple, the Apple logo, Mac, PowerMac G4, PowerMac G5, Xserve, Xserve RAID, PowerBook, iBook, Airport, AirPort Extreme, iMac, eMac, iLife, iMovie, iCal, iPhoto, iTunes, QuickTime, FireWire, iPod, iSight, AppleWorks, Macintosh, Jaguar, Panther, Mac OS, Mac OS X and Mac OS X Server are trademarks of Apple Computer, Inc. |
|