start page | rating of books | rating of authors | reviews | copyrights

Unix Power ToolsUnix Power ToolsSearch this book

28.15. Handling Lots of Text with Temporary Files

Sometimes you need to execute a command with a long list of files for arguments. Here's an easy way to create that list without having to type each filename yourself -- put the list in a temporary file:

'...' Section 28.14

% ls > /tmp/mikel
% vi /tmp/mikel
 ...edit out any files you don't want...
% process-the-files `cat /tmp/mikel`
% rm /tmp/mikel

I added the vi step to remind you that you can edit this list; for example, you may want to delete a few files that you don't want to process.

Possible problems: if the list is long enough, you may end up with a command line that's too long for your shell to process. If this happens, use xargs (Section 28.17). If your system doesn't have xargs, there are other workarounds doesn't that should solve the problem.

-- ML



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.