crab [options] [-db filename] [path] [path]... [sql | cmd] [sql | cmd]...
filename is a crab database file to open or create.
If not specified, Crab will use the default database file
path is a path to scan, wildcards are supported on MacOS but not yet on Windows.
If no path is specified, Crab will open the database to query previous scan results. If you specify multiple paths they will all be scanned. If a path has spaces wrap it in double quotes
sql | cmd is a SQL query or Crab command, wrapped in double quotes
You can specify multiple queries, quote them separately
|-batch||no Crab shell, exit after executing scan/SQL|
|-case||new scans will be case sensitive|
|-color lightmode||use colors suitable for command line window with a light background|
|-column||set output mode to 'column'|
|-csv||set output mode to 'csv'|
|-dict||set output mode to 'dict'|
|-encoding 'name'||set the encoding to use for file I/O|
|-init scriptfile||read and process Crab script file|
|-line||set output mode to 'line'|
|-list||set output mode to 'list'|
|-maxdepth n||scan only to depth n|
|-mount||scan includes subdirectories that are mounted drives|
|-nocolor||disable color output|
|-nullvalue 'string'||set text string for NULL values|
|-refresh||refresh scan results when opening database|
|-separator 'string'||set output field separator (,)|
Scan current directory recursively to default database, then open a Crab prompt
C:\> crab .
Open a Crab prompt on the default database to query previous scan results
Scan whole disk and save scan data to specified file, exit after scan
C:\> crab -batch -db wholedisk20150828.crdb C:\
Start Crab with color scheme suitable for console with light background, and open specified scan data file
C:\> crab -color lightmode -db wholedisk20150828.crdb
Scan current directory tree to default database file, report biggest files, and exit
C:\> crab -batch . "select fullpath, bytes from files order by bytes desc limit 5"
Scan current directory and its contents, but no deeper, then open a Crab prompt
C:\> crab -maxdepth 1 .
Scan dir1 and dir2 in current directory recursively, then open a Crab prompt
C:\> crab dir1 dir2
Command line option to run Crab without a Crab prompt
Crab will exit after executing the scans or SQL commands you've specified, without giving a Crab prompt. Results are returned as lists, with a comma separator.
When to use the batch option
C:\> crab -batch -db C:\Users\johnsmith\wholedisk.crdb C:\
C:\> crab -batch . "select fullpath, bytes from files order by bytes desc limit 3"
C:\Users\johnsmith\myproject\my off switch app store png images\my off switch app store ipad retina image2.idraw,48276511
Instant SQL: Run query against scan made earlier, and pipe the results to grep
C:\> crab -batch "select fullpath from files where name like '%apsw%' " | findstr '\.so'
Scan given path and run a file of crab commands and/or SQL queries called genhelp.crab
C:\> crab -batch C:\Users\johnsmith\Dropbox\PYTHONDROPBOX\sqlsys\ '%read genhelp.crab'
See %read command
To process a text file containing multiple Crab commands or SQL use the %read command
See -separator option
To change the separator used in list mode results as returned by -batch
-color lightmode | default | off
Command line option to specify Crab color scheme at start up.
When to use the color option
On Windows the default color scheme is designed for a command line window with a dark background
C:\> crab -color lightmode
C:\> crab -color off
Specifies how Crab should map byte sequences to characters when reading and writing files.
Affects reading from the fileslines table, and the %import and %autoimport commands. Writing is also affected for Crab's writeln and write functions, and the %output command.
Default value is utf8:skipfile. Crab will correctly interpret UTF-8 and ASCII encoded characters, and when querying fileslines will silently skip to the next file when it meets a non-utf8 character. This prevents binary file contents from being echoed to screen.
Read and write with utf8 encoding, stop with error on invalid characters
C:\> crab -encoding utf8
Read and write with cp1252 encoding, replace invalid characters by placeholder symbol
C:\> crab -encoding cp1252:replace
Read and write with utf8 encoding, on invalid character skip to next file when querying fileslines
C:\> crab -encoding utf_8:skipfile
Read and write with ascii encoding, ignore any invalid characters
C:\> crab -encoding ascii:ignore
Read and write binary using blob objects, with buffer size of 80 bytes
C:\> crab -encoding binary:80
Read and write binary using blob objects, whole file as one data row
C:\> crab -encoding binary:-1
See %encoding command
Read and process Crab script file.
Scan current directory, process prefs.crab and open Crab command line
C:\> crab -init prefs.crab .
Open default.crdb scan data, run script transposeCsv.crab, and return results to command line
C:\> crab -batch -init C:\Users\johnsmith\Dropbox\crabScripts\transposeCsv.crab
See %read command
Command line option to specify how far down the directory tree Crab should scan.
A maxdepth of 0 means scan only the file or directory objects specified for scanning, the scan isn't continued down the directory tree. If a path to a directory is given, only one item - the directory itself - will be recorded, not its contents.
A maxdepth of 1 means recurse into directory contents one level down, and so on.
If you don't specify any maxdepth, the scan continues recursing down the directory tree until everything below the scan list has been scanned. Soft links aren't followed, and remote filesystems may or may not be scanned depending on the -mount start up option.
When to use the -maxdepth option
Command line option to tell Crab to scan mounted devices when descending directory trees.
By default scans only include files and directories that match devices on the original scan list: Any subdirectories that are the mount point for a different device, will be excluded. The -mount option changes this behaviour to recurse into mounted directories too.
E.g. Scan the whole filesytem including mounted devices, and treat everything as case sensitive
C:\> crab -mount -case -batch -db alldisks.crdb C:\
Refresh scan results when opening Crab
Triggers Crab to scan the orginal list of paths again, to repopulate the database. If the scan path was originally a set of wildcards the wildcards will not be re-evaluated, but the objects that matched will be scanned again.
Currently it's slower to scan with the -refresh option than to specify the paths again.
When to use the -refresh option
C:\> crab -refresh
C:\> crab -batch -separator '|' "SELECT name, bytes FROM files ORDER BY bytes DESC LIMIT 3"
my off switch app store ipad retina image2.idraw|48276511
See %mode and %separator commands
%mode changes output layout, list mode is one of the available options
See Crab's -batch startup option
Crab's -batch startup option defaults to list mode output