bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #31240] find -exec can't access shell environment (alias or functio


From: Leif W
Subject: [bug #31240] find -exec can't access shell environment (alias or functions)
Date: Mon, 04 Oct 2010 12:42:36 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b6) Gecko/20100101 Firefox/4.0b6

URL:
  <http://savannah.gnu.org/bugs/?31240>

                 Summary: find -exec can't access shell environment (alias or
functions)
                 Project: findutils
            Submitted by: warp9pnt9
            Submitted on: Mon 04 Oct 2010 12:42:35 PM GMT
                Category: find
                Severity: 3 - Normal
              Item Group: Wrong result
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.4.2
           Fixed Release: None

    _______________________________________________________

Details:

Using diff 4.4.2 in MSYS.

I wanted a quick way to capture file name, size, modification and md5sum all
in one tab separated line.  I decided to use find -exec, and learned the
limitation of the -exec commands.  So I wrote a small shell function (below),
which does what I want.

function f_md5stat ( )
{
    stat --printf="%n\t%s\t%y\t$md5" $1; md5sum "$1" | cut -d\  -f1;
}

However, find can not access anything in the shell's environment.  Not sure
if that is by design, but seems to be an odd limitation.

I put the function into a file and put the file into /bin, for a quick test,
and it will work that way.  However, I wish to have several functions in one
file.  The workaround I have found is to use a "case" to detect the way the
script was called (or what the 0th or 1st arguments were), and use that to
determine which internal shell function to use.

The other custom function will call find on 2+ directory trees, pass each
argument to the f_md5stat function, to generate detailed lists, which I will
then use for the purpose of comparing and (for now, manually) synching files.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Mon 04 Oct 2010 12:42:35 PM GMT  Name: md5stat  Size: 257B   By:
warp9pnt9

<http://savannah.gnu.org/bugs/download.php?file_id=21608>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?31240>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]