1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice

Welcome To SNBForums

SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.

If you'd like to post a question, simply register and have at it!

While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!

Find command missing tons of actions.

Discussion in 'ASUS Wireless' started by unsynaps, Mar 11, 2018.

  1. unsynaps

    unsynaps Regular Contributor

    Joined:
    Nov 9, 2014
    Messages:
    177
    Location:
    Halethorpe, MD
    Is there any reason the 'find' command on the routers are missing tons of actions compared to the BusyBox documentation? Specifically -type and -maxdepth?

    This:
    Code:
    BusyBox v1.24.1 (2018-03-10 13:31:44 EST) multi-call binary.
    
    Usage: find [-HL] [PATH]... [OPTIONS] [ACTIONS]
    
    Search for files and perform actions on them.
    First failed action stops processing of current file.
    Defaults: PATH is current directory, action is '-print'
    
            -L,-follow      Follow symlinks
            -H              ...on command line only
    
    Actions:
            ! ACT           Invert ACT's success/failure
            ACT1 [-a] ACT2  If ACT1 fails, stop, else do ACT2
            ACT1 -o ACT2    If ACT1 succeeds, stop, else do ACT2
                            Note: -a has higher priority than -o
            -name PATTERN   Match file name (w/o directory name) to PATTERN
            -iname PATTERN  Case insensitive -name
            -mtime DAYS     mtime is greater than (+N), less than (-N),
                            or exactly N days in the past
    If none of the following actions is specified, -print is assumed
            -print          Print file name
            -print0         Print file name, NUL terminated
            -exec CMD ARG ; Run CMD with all instances of {} replaced by
                            file name. Fails if CMD exits with nonzero
    VS This:
    Code:
    find [PATH]... [EXPRESSION]
    
    Search for files. The default PATH is the current directory, default EXPRESSION is '-print'
    
    EXPRESSION may consist of:
    
            -follow         Follow symlinks
            -xdev           Don't descend directories on other filesystems
            -maxdepth N     Descend at most N levels. -maxdepth 0 applies
                            tests/actions to command line arguments only
            -mindepth N     Don't act on first N levels
            -name PATTERN   File name (w/o directory name) matches PATTERN
            -iname PATTERN  Case insensitive -name
            -path PATTERN   Path matches PATTERN
            -regex PATTERN  Path matches regex PATTERN
            -type X         File type is X (X is one of: f,d,l,b,c,...)
            -perm NNN       Permissions match any of (+NNN), all of (-NNN),
                            or exactly NNN
            -mtime DAYS     Modified time is greater than (+N), less than (-N),
                            or exactly N days
            -mmin MINS      Modified time is greater than (+N), less than (-N),
                            or exactly N minutes
            -newer FILE     Modified time is more recent than FILE's
            -inum N         File has inode number N
            -user NAME      File is owned by user NAME (numeric user ID allowed)
            -group NAME     File belongs to group NAME (numeric group ID allowed)
            -depth          Process directory name after traversing it
            -size N[bck]    File size is N (c:bytes,k:kbytes,b:512 bytes(def.))
                            +/-N: file size is bigger/smaller than N
            -links N        Number of links is greater than (+N), less than (-N),
                            or exactly N
            -print          Print (default and assumed)
            -print0         Delimit output with null characters rather than
                            newlines
            -exec CMD ARG ; Run CMD with all instances of {} replaced by the
                            matching files
            -prune          Stop traversing current subtree
            -delete         Delete files, turns on -depth option
            (EXPR)          Group an expression
     
  2. Please support SNBForums! Just click on this link before you buy something from Amazon and we'll get a small commission on anything you buy. Thanks!
  3. Ronald Schwerer

    Ronald Schwerer Regular Contributor

    Joined:
    Jan 8, 2017
    Messages:
    173
    Don't know but I'm curious which FW you are running. I'm on the latest official (384.20308) and I have BusyBox v1.17.4 (2018-01-31 17:28:03 CST). It has even different options:
    BusyBox v1.17.4 (2018-01-31 17:28:03 CST) multi-call binary.
    Usage: find [PATH]... [EXPRESSION]
    Search for files. The default PATH is the current directory,
    default EXPRESSION is '-print'
    EXPRESSION may consist of:
    -follow Follow symlinks
    -mindepth N Don't act on first N levels
    -name PATTERN File name (w/o directory name) matches PATTERN
    -iname PATTERN Case insensitive -name
    -mtime DAYS Modified time is greater than (+N), less than (-N),
    or exactly N days
    -print Print (default and assumed)
    -print0 Delimit output with null characters rather than
    newlines
    -exec CMD ARG ; Run CMD with all instances of {} replaced by the
    matching files​

    I guess it is up to the dev team to decide how much to include in the build.
     
    Last edited: Mar 11, 2018
  4. RMerlin

    RMerlin Super Moderator

    Joined:
    Apr 14, 2012
    Messages:
    27,094
    Location:
    Canada
    Which models and which firmware versions are you comparing?
     
  5. Ronald Schwerer

    Ronald Schwerer Regular Contributor

    Joined:
    Jan 8, 2017
    Messages:
    173
    RT-AC68P running ASUS WRT Official build 384.20308 = BusyBox v1.17.4
     
  6. RMerlin

    RMerlin Super Moderator

    Joined:
    Apr 14, 2012
    Messages:
    27,094
    Location:
    Canada
    I was referring to the original poster. I should normally have the same BB options on all models that I support, however these will be different from the stock firmware.
     
  7. ColinTaylor

    ColinTaylor Part of the Furniture

    Joined:
    Mar 31, 2014
    Messages:
    5,506
    Location:
    UK
    He was comparing his router's output (using your 384 firmware I believe) to the Command Help that is posted on the busybox website.
     
  8. RMerlin

    RMerlin Super Moderator

    Joined:
    Apr 14, 2012
    Messages:
    27,094
    Location:
    Canada
    Busybox is highly configurable, and not all options are enabled, for performance reasons (i.e. every time you run any Busybox command, you end up loading and running the whole busybox executable, with all of its memory usage).
     
  9. joegreat

    joegreat Very Senior Member

    Joined:
    Jan 9, 2013
    Messages:
    1,668
    Location:
    Vienna, Austria
    I think that Entware is your friend for this topic:
    [email protected]:/tmp/mnt/ac87u# /opt/bin/find --help
    Usage: /opt/bin/find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
    default path is the current directory; default expression is -print
    expression may consist of: operators, options, tests, and actions:
    operators (decreasing precedence; -and is implicit where no others are given):
    ( EXPR ) ! EXPR -not EXPR EXPR1 -a EXPR2 EXPR1 -and EXPR2
    EXPR1 -o EXPR2 EXPR1 -or EXPR2 EXPR1 , EXPR2
    positional options (always true): -daystart -follow -regextype
    normal options (always true, specified before other expressions):
    -depth --help -maxdepth LEVELS -mindepth LEVELS -mount -noleaf
    --version -xdev -ignore_readdir_race -noignore_readdir_race
    tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N
    -cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME
    -ilname PATTERN -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN
    -links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE
    -nouser -nogroup -path PATTERN -perm [-/]MODE -regex PATTERN
    -readable -writable -executable
    -wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N
    -used N -user NAME -xtype [bcdpfls]
    -context CONTEXT
    actions: -delete -print0 -printf FORMAT -fprintf FILE FORMAT -print
    -fprint0 FILE -fprint FILE -ls -fls FILE -prune -quit
    -exec COMMAND ; -exec COMMAND {} + -ok COMMAND ;
    -execdir COMMAND ; -execdir COMMAND {} + -okdir COMMAND ;
    Report (and track progress on fixing) bugs via the findutils bug-reporting
    page at http://savannah.gnu.org/ or, if you have no web access, by sending
    email to <[email protected]>.

    [email protected]:/tmp/mnt/ac87u# /opt/bin/find --version
    find (GNU findutils) 4.6.0
    Copyright (C) 2015 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    Written by Eric B. Decker, James Youngman, and Kevin Dalley.
    Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS(FTS_CWDFD) CBO(level=2)
     
Please support SNBForums! Just click on this link before you buy something from Amazon and we'll get a small commission on anything you buy. Thanks!