Using UNIX find to generate TAGS files when the $CWD contains a space or special character
Question
The following UNIX one-liner looks for Python files below the CWD and adds them to a TAGS file for Emacs (or we could do the same with Ctags).
find . -name *.py -print | xargs etags
This breaks if the CWD has a space or other unusual character in its name. -print0
or -ls
don't seem to help, in spite of what man find
says. Is there a neat way around this?
Solution
find . -name '*.py' -print0 | xargs -0 etags
should do the trick -- you need the -0
arg to xargs to match the -print0
properly.
edit
you probably need the quotes around *.py
as well, if there are any .py files in the current directory.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow