from wikipedia:
1.
find . -name "*.foo" -print0 | xargs -0 grep bar
The above command uses GNU specific extensions to find and xargs to separate filenames using the null character;
What is the null character? What is the significance of "separate filenames using the null character;"? why should we do that? Where is the null character specified?
2.
find . -name "*.foo" -print0 | xargs -0 -t -r vi
The above command is similar to the former one, but launches the vi editor for each of the files. The -t prints the command to stderr before issuing it. The -r is a GNU extension that tells xargs not to run the command if no input was received.
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Mar 19 2009 15:56:33)
Too many edit arguments: "vi"
More info with: "vim -h"
lin309-05:~/workspace/ruby/icm$ find . -name "*.foo" -print0 | xargs -0 -t -r vi
lin309-05:~/workspace/ruby/icm$ find . -name "*.rb" -print0 | xargs -0 -t -r vi
vi ./util.rb ./test_utf8.rb ...
Vim: Warning: Input is not from a terminal
28 files to edit
first what is the significance of -r. second, after quitting from vi by :q
the shell hangs. There is a blinking cursor, but no keyboard input is accepted. It happened twice.
3.
find . -name "*.foo" -print0 | xargs -0 -I xxx mv xxx /tmp/trash
The above command uses string xxx instead of {} as the argument list marker.
But when I tried this:
find . -name "*.foo" -print0 | xargs -0 -I xxx mv xxx /tmp/
it gives:
mv: preserving permissions for `/tmp/minf.foo': Operation not supported
mv: preserving permissions for `/tmp/state.foo': Operation not supported
changing the I switch to i (as it is ubuntu) gives this :
lin309-05:~/workspace/ruby/icm$ ls *.foo
minf.foo state.foo
lin309-05:~/workspace/ruby/icm$ find . -name "*.foo" -print0 | xargs -0 -i xxx mv xxx /tmp/
xargs: xxx: No such file or directory
4.
find . -maxdepth 1 -type f -name "*.ogg" -print0 | xargs -0 -r cp -v -p --target-directory=/home/media
The command above does the same as:
cp -v -p *.ogg /home/media
For the first version why the cp is accepting the second argument as source argument coming from 'find' where as we know the source argument is first argument in case of cp.
Also it says You can also use -L to limit the number of arguments. If you do that, the command will be run repeatedly until it’s out of arguments. Thus, -L1 runs the command once for each argument (needed for tools like tar and such).
I didn't understand it at all. What is it talking about?