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 supported on MacOS, but not yet on Windows.
If no path is specified, Crab will open the database to query previous scan results
sql | cmd is a SQL query or Crab command, wrapped in quotes
|-batch||no Crab shell, exit after executing scan/SQL|
|-case||new scans will be case sensitive|
|-color darkmode||use colors suitable for dark 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
$ crab .
Open a Crab prompt on the default database to query previous scan results
Scan whole disk from root and save scan data to specified file, exit after scan. Mounted drives won't be scanned.
$ crab -batch -db wholedisk20150828.crdb /
Start crab with color scheme suitable for terminal with dark background, and open specified scan data file
$ crab -color darkmode -db wholedisk20150828.crdb
Scan current directory tree to default database, report biggest files, and exit
$ 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
$ crab -maxdepth 1 .
Scan both this directory and that directory recursively to default database, then open a Crab prompt
$ crab ~/this ~/that
Scan all text files in the current directory to default database, then open a Crab prompt
$ crab *.txt
Command line option to run Crab without a Crab command line.
Crab will exit after executing the scans or SQL commands you've specified. Results are returned as lists, with a comma separator.
When to use the batch option
$ crab -batch '%refresh'
$ crab -batch -db ~/wholedisk.crbd /
$ crab -batch ~/Dropbox "SELECT fullpath FROM files WHERE extension = '.exe' "
$ crab -batch . "select fullpath, bytes from files order by bytes desc limit 3"
/Users/peterdalloz/myproject/my off switch app store png images/my off switch app store ipad retina image2.idraw,48276511
Instant SQL: Run query against earlier scan, and pipe the results to grep
$ crab -batch "SELECT fullpath from files where name like '%apsw%' " | grep '\.so'
Scan given path and run a file of crab commands and/or SQL queries called genhelp.crab
$ crab -batch ~/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
Command line option to set future scans as case sensitive.
Default behaviour is that scans are case insensitive, this option changes that.
Existing scan data is unaffected.
When to use the case option
When scanning a case sensitive file system, such as a time machine backup.
$ crab -case .
-color darkmode | default | off
Command line option to specify Crab color scheme at start up.
When to use the color option
The default color scheme is designed to be readable with a light colored background
$ crab -color darkmode
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
$ crab -encoding utf8
Read and write with cp1252 encoding, replace invalid characters by placeholder symbol
$ crab -encoding cp1252:replace
Read and write with utf8 encoding, on invalid character skip to next file when querying fileslines
$ crab -encoding utf_8:skipfile
Read and write with ascii encoding, ignore any invalid characters
$ crab -encoding ascii:ignore
Read and write binary using blob objects, with buffer size of 80 bytes
$ crab -encoding binary:80
Read and write binary using blob objects, whole file as one data row
$ crab -encoding binary:-1
See %encoding command
Read and process Crab script file.
Scan current directory, process prefs.crab and open Crab command line
$ crab -init prefs.crab .
Open default.crdb scan data, run script transposeCsv.crab, and return results to bash
$ crab -batch -init ~/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
$ crab -mount -case -batch -db alldisks.crdb /
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.
When to use the -refresh option
$ crab -refresh
$ 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