diff <(find / -mount |find2perl) <(find / |find2perl) # no diffs?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


How do I do this in perl?:

  find / -mount
    # want to stay in one-file-system

No help here:

  ~ $ perl -v|grep 'is perl'
  This is perl, v5.10.0 built for i386-linux-thread-multi
  ~ $ diff <(find / -mount |find2perl) <(find / |find2perl); echo diff retval: $?
  diff retval: 0
  ~ $


Re: diff <(find / -mount |find2perl) <(find / |find2perl) # no diffs?

Quoted text here. Click to load it

I've never seen that -mount option before, but my local man page says:

       -mount Don't  descend  directories  on other filesystems.  An alternate
              name for -xdev, for compatibility with some  other  versions  of

So don't use -mount, use standard -xdev instead.


Quoted text here. Click to load it

That's not how you use find2perl at all. You write your find command

  find / -xdev

and then substitute find2perl for find

  find2perl / -xdev

and that prints a perl script which does the equivalent of the find command.
It makes no sense to have find2perl at the end of a pipeline, since it
doesn't do anything with stdin.

Alan Curry

Re: diff <(echo find / -mount |find2perl) <(echo find / |find2perl) # no diffs?

Sorry! In trimming the subject I must have deleted the 'echo's.
Subject is now correct.

Quoted text here. Click to load it

mount is more mnemonic

Quoted text here. Click to load it

oops! How did I leave out the echos, I meant:

  ~ $ diff <(echo find / -mount |find2perl) <(echo find / |find2perl); echo $?
  ~ $ diff <(echo find / -xdev  |find2perl) <(echo find / |find2perl); echo $?

Quoted text here. Click to load it

Again, sorry for the confusion..

The above diffs compare the output of 'find2perl' for two
different inputs one has the '-mount' the other does not

This is off topic a bit:

   ~ $ man bash|col -b| sed -ne '/^ *Process Substitution/,/^$/p'
   Process Substitution
       Process substitution is supported on systems that support  named  pipes
       (FIFOs)  or the /dev/fd method of naming open files.  It takes the form
       of <(list) or >(list).  The process list is run with its input or  out-
       put connected to a FIFO or some file in /dev/fd.  The name of this file
       is passed as an argument to the current command as the  result  of  the
       expansion.   If the >(list) form is used, writing to the file will pro-
       vide input for list.  If the <(list) form is used, the file  passed  as
       an argument should be read to obtain the output of list.

Quoted text here. Click to load it

man find2perl supports what you say


  ~ $ diff <(find2perl / -xdev) <(find2perl /); echo $?
  <     my ($dev,$ino,$mode,$nlink,$uid,$gid);
  <     (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
  <     !($File::Find::prune |= ($dev != $File::Find::topdev));
  > ;

I'll try the 'find2perl / -xdev' script on Friday.


Quoted text here. Click to load it

Site Timeline