-1

I was reading a page about the performance of delete operation on thousands of files and it mentions the command below

perl -e 'for(<*>){((stat)[9]<(unlink))}'

Could anyone explain me why I have a 'command not found' while calling command 'stat' from the command-line while it's working through perl?

amphetamachine
  • 27,620
  • 12
  • 60
  • 72
  • 1
    What do you mean by "calling 'stat' from the command-line"? The `stat` Perl function can only be called from within a Perl program (such as the one you posted). – ikegami Feb 09 '16 at 17:16
  • 2
    [stat](http://p3rl.org/stat) is not [stat](http://linux.die.net/man/1/stat). – choroba Feb 09 '16 at 17:25
  • You can replicate `stat` on solaris with `truss`. Off the top of my head, something like `truss -t lstat64 -v lstat64 ls ` – Sobrique Feb 09 '16 at 21:53
  • I though the stat comman in perl in the one you see in the man page. Therefore on my bash prompt I just tried to call 'stat' but I haven't it installed. So I want to know if perl is actually calling the system command 'stat' (I think it's the case) and if it's, is there a way for me to call it without using truss. I saw some pages where the 'stat' command can be called from the shell prompt – user1649114 Feb 10 '16 at 09:05
  • No, perl is not calling the external program `stat`, nor the shell built-in `stat`. It calls the [C library function `stat`](http://linux.die.net/man/2/stat). So no, you can't call `stat` (the program) without installing it. Why can't you just use perl? – ThisSuitIsBlackNot Feb 10 '16 at 17:37
  • Thanks for the clarification. It was just a question but of course I'll use perl as it's the fastest and working solution. – user1649114 Feb 11 '16 at 09:19

1 Answers1

0

The stat perl function is different from the stat program.

Likely you may be running this from an environment that doesn't have a stat program installed (Windows).

amphetamachine
  • 27,620
  • 12
  • 60
  • 72