FIND command

Discussion about using NAS on Linux and Unix OS.
Post Reply
hornetbzz
Getting the hang of things
Posts: 97
Joined: Tue Apr 07, 2009 8:10 am

FIND command

Post by hornetbzz »

Hello,

I have an easy question for specialists (I guess) :

The QNAP linux native "FIND" command does not allow "-mmin" option but only "mtime".

So I installed :

Code: Select all

ipkg install findutils
As I previously patched Optware as indicated here, I guess I can get the new command in /opt/bin :

Code: Select all

./opt/bin/find -name "some_file_name" -cmin 59
So far so great, at least now I can seek for old file w/o having to write & use a special shell :oops: :-)

Then the easy question :

HOW to get the "new" find command replacing the old one :?:
(In other world, how to avoid using the path "/opt/bin/command" but directly invoking "command" for an easy use)

Thx in advance
The Force to be with you !!
--------------------------------------
TS509 Pro (2.1.5 Build 0408T), Apache/2.2.6 (Unix) DAV/2 mod_ssl/2.2.6 OpenSSL/0.9.8e , PHP 5.2.9, 5 x 1.5 To (RAID5), 1 nux Firewall, 1 Netgear GS724T, 3 other machines (Debian)
User avatar
schumaku
Guru
Posts: 43579
Joined: Mon Jan 21, 2008 4:41 pm
Location: Kloten (Zurich), Switzerland -- Skype: schumaku
Contact:

Re: FIND command

Post by schumaku »

Consider to change the default search path (shell variable PATH) so /opt/bin has priority - but only for your scripts, and if required after your interactive logins.

Example (a TS-109 here, but check your specific unit) - with ipkg installed...so change
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin

[~] # find --version
BusyBox v1.01 (2009.07.07-21:09+0000) multi-call binary
Usage: find [PATH...] [EXPRESSION]
...

...to something like this:
[~] # PATH=/opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/sbin
[~] # export PATH

[~] # find --version
GNU find version 4.2.32
Built using GNU gnulib version 8e128ebf42e16c8631f971a68f188c30962818be
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION


Do _not_ try to globally superceede this, as it might create incomaptibilities with QNAP or 3rd party supplied scripts please.

Enjoy!

-Kurt.
hornetbzz
Getting the hang of things
Posts: 97
Joined: Tue Apr 07, 2009 8:10 am

Re: FIND command

Post by hornetbzz »

Many thx for the good explanation about PATH that I was really missing.

Actually I was hoping being able to link one command with one path and not globally.

b/r and merry Xmas
The Force to be with you !!
--------------------------------------
TS509 Pro (2.1.5 Build 0408T), Apache/2.2.6 (Unix) DAV/2 mod_ssl/2.2.6 OpenSSL/0.9.8e , PHP 5.2.9, 5 x 1.5 To (RAID5), 1 nux Firewall, 1 Netgear GS724T, 3 other machines (Debian)
User avatar
schumaku
Guru
Posts: 43579
Joined: Mon Jan 21, 2008 4:41 pm
Location: Kloten (Zurich), Switzerland -- Skype: schumaku
Contact:

Re: FIND command

Post by schumaku »

hornetbzz wrote:Actually I was hoping being able to link one command with one path and not globally.
Understood your request in this way, but considered changing the path within the context is a much more secure (and universal!) approach for other commands. Of course you _could_ consider to modify the find symlink pointing to the BusyBox from autoexec.sh. This won't be that simple, requires mounting the flash drive to create/update autoexec.sh (see Wiki), it can go badly wrong if e..g the ipkg opt path won't be there one day (e.g. tricky update), beyond it could easily torpedize other scripts.

Seasonal greetings,

-Kurt.
hornetbzz
Getting the hang of things
Posts: 97
Joined: Tue Apr 07, 2009 8:10 am

Re: FIND command

Post by hornetbzz »

Thx again.

So I understand the right way for doing what I want is to keep the BusyBox commands as they are if I wish to keep safe - not jeopardizing previously existing scripts - , and add aliases.

For example in this particular case for changing the 'FIND' command :

Code: Select all

alias find='/opt/bin/find'
Which works well when run in command line in the open session.

The remaining point is :

Where to define these aliases (as I tried in /etc/profile, restarted a new tty but observed not change in the 'find --version' result: always the busybox command)

Sorry again as I guess these are probably stupid questions from a specialist standpoint.
The Force to be with you !!
--------------------------------------
TS509 Pro (2.1.5 Build 0408T), Apache/2.2.6 (Unix) DAV/2 mod_ssl/2.2.6 OpenSSL/0.9.8e , PHP 5.2.9, 5 x 1.5 To (RAID5), 1 nux Firewall, 1 Netgear GS724T, 3 other machines (Debian)
Post Reply

Return to “Linux & Unix (NFS)”