Re: [Hampshire] Executing a command on a list of files?

Top Page

Reply to this message
Author: Daniel Pope
Date:  
To: Hampshire LUG Discussion List
Subject: Re: [Hampshire] Executing a command on a list of files?
Andy Smith wrote:
> On Wed, Feb 21, 2007 at 08:42:04PM -0500, Andy Random wrote:
>> Hi,
>>
>> I have several files which contain lists of files that I want to execute a
>> command on.
>
> for f in $(cat /some/list ./of/many ./files); do whatever_comand $f; done


Or, if your filenames potentially contain spaces, you may need

cat /some/list ./of/many ./files | xargs -I '{}' whatever_command '{}'

Dan