How can I substitute into this shell command?

You don't need to invoke ls to get at the stat information, find already did that. Use something like this instead (same output as ls -ln):

find -follow \( -group 39 -o -acl_group 39 \) -printf '%M  %n %U %G %s %Cb %Cd %CH:%CM %p\n'

See section 3.2.2 of the GNU find manual for more on the format directives.

Edit

To apply this to multiple group ids from a file:

while read; do
  find -follow \( -group $REPLY -o -acl_group $REPLY \) \
    -printf '%M  %n %U %G %s %Cb %Cd %CH:%CM %p\n'      \
    1> $HOME/results.$REPLY.log                         \
    2> $HOME/error.$REPLY.log
done < group_id_file

What about a for statement? something like:

for f in `cat file_with_entries`; do
    find -follow \( -group $f -o -acl_group $f \) -exec ls -ln {} \; 2> $HOME/error.$f.log 1> $HOME/results.$f.log
done

Tags:

Shell

Find

Files