All Projects → upcrob → Fsq

upcrob / Fsq

Licence: bsd-3-clause
A tool for querying the file system with a SQL-like language.

Programming Languages

go
31211 projects - #10 most used programming language
language
365 projects

Projects that are alternatives of or similar to Fsq

Fd
A simple, fast and user-friendly alternative to 'find'
Stars: ✭ 19,851 (+32985%)
Mutual labels:  cli, terminal, command-line, search, filesystem, tool, regex
Nnn
n³ The unorthodox terminal file manager
Stars: ✭ 13,138 (+21796.67%)
Mutual labels:  cli, terminal, command-line, search, filesystem
Lucid
A simple mock-application for programs that work with child processes
Stars: ✭ 45 (-25%)
Mutual labels:  cli, terminal, command-line, tool
Diskus
A minimal, fast alternative to 'du -sh'
Stars: ✭ 674 (+1023.33%)
Mutual labels:  cli, command-line, filesystem, tool
Ripgrep
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
Stars: ✭ 28,564 (+47506.67%)
Mutual labels:  cli, command-line, search, regex
Grex
A command-line tool and library for generating regular expressions from user-provided test cases
Stars: ✭ 4,847 (+7978.33%)
Mutual labels:  cli, terminal, tool, regex
Csview
📠 A high performance csv viewer with cjk/emoji support.
Stars: ✭ 208 (+246.67%)
Mutual labels:  cli, terminal, command-line, tool
Teip
Select partial standard input and replace with the result of another command efficiently
Stars: ✭ 280 (+366.67%)
Mutual labels:  cli, terminal, command-line, tool
Laravel Zero
A PHP framework for console artisans
Stars: ✭ 2,821 (+4601.67%)
Mutual labels:  cli, terminal, command-line, tool
Pastel
A command-line tool to generate, analyze, convert and manipulate colors
Stars: ✭ 3,742 (+6136.67%)
Mutual labels:  cli, terminal, command-line, tool
Bat
A cat(1) clone with wings.
Stars: ✭ 30,833 (+51288.33%)
Mutual labels:  cli, terminal, command-line, tool
Nve
Run any command on specific Node.js versions
Stars: ✭ 531 (+785%)
Mutual labels:  cli, terminal, command-line
Googler
🔍 Google from the terminal
Stars: ✭ 5,594 (+9223.33%)
Mutual labels:  terminal, command-line, search
Sultan
Sultan: Command and Rule over your Shell
Stars: ✭ 625 (+941.67%)
Mutual labels:  cli, terminal, command-line
Buku
🔖 Personal mini-web in text
Stars: ✭ 4,825 (+7941.67%)
Mutual labels:  terminal, command-line, search
Rang
A Minimal, Header only Modern c++ library for terminal goodies 💄✨
Stars: ✭ 1,080 (+1700%)
Mutual labels:  cli, terminal, command-line
Crex
Explore, test, and check regular expressions in the terminal.
Stars: ✭ 54 (-10%)
Mutual labels:  cli, terminal, regex
Jtc
JSON processing utility
Stars: ✭ 425 (+608.33%)
Mutual labels:  cli, command-line, tool
Cheat.sh
the only cheat sheet you need
Stars: ✭ 27,798 (+46230%)
Mutual labels:  cli, terminal, command-line
Crossline
A small, self-contained, zero-config, MIT licensed, cross-platform, readline and libedit replacement.
Stars: ✭ 53 (-11.67%)
Mutual labels:  cli, terminal, command-line

fsq

The fsq ('file system query' - pronounced, 'fisk') utility is a tool for doing ad-hoc queries against a file system using a SQL-like expression language. This is useful for finding files that match certain criteria without writing a one-off script to do so.

Installation

Download the binary for your platform and add it to your command line path.

Usage

Query Structure

fsq takes a single argument: the expression. This expression is composed of the following parts:

<attribute list> in <locations> where <conditions>

Example Queries

To recursively find all files under the '/data' directory that start with the characters 'hello' and are larger than 5 mb, the following query could be used:

fsq "name in '/data' where name startswith 'hello' and size > 5m"

If the location (in the above case, '/data') is omitted, fsq will default to the current directory:

fsq "name where name startswith 'hello' and size > 5m"

Multiple locations can be specified as well:

fsq "name in '/opt', '/media' where size > 5m"

The attribute list specifies which attributes are printed to standard out by fsq. In the above case, this is just the filename ('name'). The following example will print both the path to the file and the size (in bytes):

fsq "path,size in '/opt' where size > 5m"

Supported Attributes

  • name
  • path
  • size
  • fsize (can be used in the attribute list, but cannot be queried)
  • content (content can be queried, but cannot be added to the attribute list for printing)
  • modified (format: 'MM/DD/YYYY' or 'MM/DD/YYYY hh:mm:ss')
  • stats (can be used in the attribute list, but cannot be queried)

Supported Conditional Operators

  • <
  • <=
  • >
  • >=
  • =
  • !=
  • startswith
  • endswith
  • isdir (this operator does not take any arguments)
  • isfile (this operator does not take any arguments)
  • contains
  • ignorecase (must be followed by '=', '!=', 'startswith', 'endswith', or 'contains')
  • matches (regular expression matching)

Logic Operators

Parentheses as well as the logical operators or, and, and not can be used to group conditions. For example:

fsq "name in '.' where name startswith 'hello' or (isdir and not name startswith 'world')"

Size Qualifiers

The following size qualifiers can be appended to integer values to indicate non-default units. These are especially useful when specifying file sizes in expressions. If no size qualifier is appended to an integer, fsq compares the value in bytes.

  • k - Kilobytes
  • m - Megabytes
  • g - Gigabytes

For example, to find all files greater than 10 kilobytes and less than 1 megabyte:

fsq "path where size > 10k and size < 1m"

Building

The go compiler is required to build fsq. If you have make installed, fsq can be installed with:

make install

Otherwise, the following commands will need to be run while in the fsq directory:

go get golang.org/x/tools/cmd/goyacc
go install golang.org/x/tools/cmd/goyacc
goyacc parser.y
go install
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].