find: Viewing And Editing

1 
1 9.1 Viewing And Editing
1 =======================
1 
1 To view a list of files that meet certain criteria, simply run your file
1 viewing program with the file names as arguments.  Shells substitute a
1 command enclosed in backquotes with its output, so the whole command
1 looks like this:
1 
1      less `find /usr/include -name '*.h' | xargs grep -l mode_t`
1 
1 You can edit those files by giving an editor name instead of a file
1 viewing program:
1 
1      emacs `find /usr/include -name '*.h' | xargs grep -l mode_t`
1 
1    Because there is a limit to the length of any individual command
1 line, there is a limit to the number of files that can be handled in
1 this way.  We can get around this difficulty by using 'xargs' like this:
1 
1      find /usr/include -name '*.h' | xargs grep -l mode_t > todo
1      xargs --arg-file=todo emacs
1 
1    Here, 'xargs' will run 'emacs' as many times as necessary to visit
1 all of the files listed in the file 'todo'.  Generating a temporary file
1 is not always convenient, though.  This command does much the same thing
1 without needing one:
1 
1      find /usr/include -name '*.h' | xargs grep -l mode_t |
1      xargs sh -c 'emacs "$@" < /dev/tty' Emacs
1 
1    The example above illustrates a useful trick; Using 'sh -c' you can
1 invoke a shell command from 'xargs'.  The '$@' in the command line is
1 expanded by the shell to a list of arguments as provided by 'xargs'.
1 The single quotes in the command line protect the '$@' against expansion
1 by your interactive shell (which will normally have no arguments and
1 thus expand '$@' to nothing).  The capitalised 'Emacs' on the command
1 line is used as '$0' by the shell that 'xargs' launches.
1