Re: find -print0 confusing me
- From: Stephane CHAZELAS <this.address@xxxxxxxxxx>
- Date: Wed, 21 Feb 2007 19:28:30 GMT
2007-02-21, 13:22(-06), Charles Russell:
Why does the ascii nul character not appear in the string when it is
created by a backquote? (See below.) I am trying to figure out how to
handle spaces in pathnames.
#!/usr/bin/sh
echo "straight call to find"
# make ascii nul visible by swapping for @
find . -type d -name '*' -print0 | tr "\0" @
echo
echo "calling in backquotes"
echo `find . -type d -name '*' -print0 `| tr "\0" @
output:
$ puzl.sh
straight call to find
.@./spl it@./spl it
calling in backquotes
../spl it./spl it2
The NUL byte is the string terminator. For instance, the list of
arguments passed to a command is a list of NUL terminated
strings. So the NUL byte can't be passed in an argument to a
command.
Some shells like zsh (and possibly recent versions of ksh93)
are able to pass NUL characters to their builtin commands (and
only to the builtin ones).
The code above would have /worked/ with zsh.
--
Stéphane
.
- References:
- find -print0 confusing me
- From: Charles Russell
- find -print0 confusing me
- Prev by Date: Unix Sort?
- Next by Date: Re: Unix Sort?
- Previous by thread: find -print0 confusing me
- Next by thread: Re: find -print0 confusing me
- Index(es):
Relevant Pages
|