Re: find with -exec option using complex expressions

From: Bill Marcum (bmarcum_at_iglou.com)
Date: 07/26/04


Date: 25 Jul 2004 20:11:27 -0400

On 25 Jul 2004 09:55:05 -0700, Jim
  <shija03@hotmail.com> wrote:
> Hello,
>
> I am trying to execute a "find . -exec 'somecomplex expression'
> \;", but I am failing to make it work. Can anyone help me, here is my
> example:
>
> find . -exec \( myvar={};newvar=`basename {}`;touch /here/${newvar}
> \)\;
> or
> find . -exec \( "myvar={};newvar=`basename {}`;touch
> /here/${newvar}" \)\;
>
"find -exec" does not invoke a shell unless you explicitly give a command
such as
find . -exec sh -c 'echo "This is $1"' find {} \;
When I tried this, it ran very slowly. You might want to rewrite your
script as:
find . -print | while read myvar; do
  newvar=`basename "$myvar"`
  touch "/here/${newvar}"
done

-- 
"Donna Hand of Ashburn, Va., waited five hours to see the casket and
spent about three minutes inside."  --AP news story


Relevant Pages

  • Re: how to write a program that takes arguments from commandline?
    ... Mark McIntyre wrote: ... a shell) used to invoke your program. ... argv to come from a command line. ...
    (comp.lang.c)
  • Re: Im looking for "Virtual dummy shell" in linux?
    ... > I'm looking for this kind of shell. ... > be invoked and reuturn some result to user according to command user issued. ... > 2) but don't influence to real root file system and system environment. ... since a shell is used to invoke commands (ie executable ...
    (comp.os.linux.development.system)
  • Re: xp_cmdshell
    ... Just create a regular batch file, save it in the root dir and invoke ... line shell you invoke when you go to Start> Run and enter cmd. ... >> invokes a new instance of of the command line shell, ...
    (microsoft.public.sqlserver.programming)
  • Re: X problem as root
    ... You have to export the variable XAUTHORITY before invoke su ... do not use the '-' in su command because this invoke the shell which read the ...
    (Debian-User)
  • Re: How to clear history of commands in unix
    ... This will tell you how to invoke your shell. ... May be I am not deleting the proper history file. ... Look at the man page of your shell to find out about command history. ...
    (comp.unix.admin)