Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typos suggestion #6

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@

# zfind

zfind allows you to search for files, including inside `tar`, `zip`, `7z` and `rar` archives. It makes finding files easy with a filter syntax that is similar to an SQL-WHERE clause. This means, if you know SQL, you don't have to learn or remember any new syntax just for this tool.
`zfind` allows you to search for files, including inside `tar`, `zip`, `7z` and `rar` archives. It makes finding files easy with a filter syntax that is similar to an SQL-WHERE clause. This means, if you know SQL, you don't have to learn or remember any new syntax just for this tool.

## Basic Usage

```
```shell
zfind <where> [<path>...]
```

Examples

```
```console
# find files smaller than 10KB, in the current path
zfind 'size<10k'
$ zfind 'size<10k'

# find files in the given range in /some/path
zfind 'size between 1M and 1G' /some/path
$ zfind 'size between 1M and 1G' /some/path

# find files modified before 2010 inside a tar
zfind 'date<"2010" and archive="tar"'
$ zfind 'date<"2010" and archive="tar"'

# find files named foo* and modified today
zfind 'name like "foo%" and date=today'
$ zfind 'name like "foo%" and date=today'

# find files that contain two dashes using a regex
zfind 'name rlike "(.*-){2}"'
$ zfind 'name rlike "(.*-){2}"'

# find files that have the extension .jpg or .jpeg
zfind 'ext in ("jpg","jpeg")'
$ zfind 'ext in ("jpg","jpeg")'

# find directories named foo and bar
zfind 'name in ("foo", "bar") and type="dir"'
$ zfind 'name in ("foo", "bar") and type="dir"'

# search for all README.md files and show in long listing format
zfind 'name="README.md"' -l
$ zfind 'name="README.md"' -l

# show results in csv format
zfind --csv
$ zfind --csv
```

## Where

- `AND`, `OR` and `()` parentheses are logical operators used to combine multiple conditions. `AND` means that both conditions must be true for a row to be included in the results. `OR` means that if either condition is true, the row will be included. Parentheses are used to group conditions, just like in mathematics.

Example: `'(size > 20M OR name = "temp") AND type="file"'` selects all files that are either greater than 20MB in size or are named temp.
Example: `'(size > 20M OR name = "temp") AND type="file"'` selects all files that are either greater than 20 MB in size or are named temp.

- Operators `=`, `<>`, `!=`, `<`, `>`, `<=`, `>=` are comparison operators used to compare values and file properties. The types must match, meaning don't compare a date to a file size.

Expand All @@ -54,7 +54,7 @@ Example: `'date > "2020-10-01"'` selects all files that were modified after the
- `LIKE` is case-sensitive, while `ILIKE` is case-insensitive.
- The `%` symbol is used as a wildcard character that matches any sequence of characters.
- The `_` symbol matches any single character.
- `RLIKE` allows to match a regular expression.
- `RLIKE` allows matching a regular expression.

Example: `'"name like "z%"'` selects all files whose name starts with 'z'.

Expand All @@ -73,13 +73,13 @@ Example: `'"name not like "z%"'`, `'"date not between "2010" and "2011-01-15"'`,
- Values can be numbers, text, date and time, `TRUE` and `FALSE`
- dates have to be specified in `YYYY-MM-DD` format
- times have to be specified in 24h `HH:MM:SS` format
- numbers can be written as sizes by appending `B`, `K`, `M`, `G` and `T` to specify bytes, KB, MB, GB and TB.
- numbers can be written as sizes by appending `B`, `K`, `M`, `G` and `T` to specify bytes, KB, MB, GB, and TB.
- empty strings and `0` evaluate to `false`


## Properties

The following file properies are available:
The following file properties are available:

| name | description |
|-------------|----------------------------------------------------------------|
Expand All @@ -89,16 +89,16 @@ The following file properies are available:
| size | file size (uncompressed) |
| date | modified date in YYYY-MM-DD format |
| time | modified time in HH-MM-SS format |
| ext | short file extension (e.g. `txt`) |
| ext2 | long file extension (two parts, e.g. `tar.gz`) |
| ext | short file extension (e.g., `txt`) |
| ext2 | long file extension (two parts, e.g., `tar.gz`) |
| type | `file`, `dir`, or `link` |
| archive | archive type: `tar`, `zip`, `7z`, `rar` or empty |

Helper properties

| name | description |
|-------------|----------------------------------------------------------------|
| today | todays date |
| today | today's date |


## Supported archives
Expand All @@ -116,11 +116,11 @@ Helper properties

`zfind` does not implement actions like `find`, instead use `xargs -0` to execute commands:

```
```shell
zfind --no-archive 'name like "%.txt"' -0 | xargs -0 -L1 echo
```

zfind can also produce `--csv` that can be piped to other commands.
`zfind` can also produce `--csv` that can be piped to other commands.


## Configuration
Expand All @@ -130,7 +130,7 @@ Set the environment variable `NO_COLOR` to disable color output.

## Installation

zfind is built for a number of platforms by GitHub actions.
`zfind` is built for a number of platforms by GitHub actions.

Download a binary from [releases](https://github.com/laktak/zfind/releases) and place it in your `PATH`.

Expand All @@ -144,7 +144,7 @@ brew install zfind

### Arch Linux

zfind is available in the AUR as [zfind](https://aur.archlinux.org/packages/zfind/):
`zfind` is available in the AUR as [zfind](https://aur.archlinux.org/packages/zfind/):

```
paru -S zfind
Expand Down
2 changes: 1 addition & 1 deletion cmd/zfind/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Examples:
# show results in csv format
zfind --csv

The following file properies are available:
The following file properties are available:

name name of the file
path full path of the file
Expand Down
6 changes: 3 additions & 3 deletions cmd/zfind/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ func main() {
var cli struct {
FilterHelp bool `short:"H" help:"Show where-filter help."`
Long bool `short:"l" help:"Show long listing format."`
Csv bool `help:"Show listing as csv."`
Csv bool `help:"Show listing as CSV."`
ArchiveSeparator string `help:"Separator between the archive name and the file inside" default:"//"`
FollowSymlinks bool `short:"L" help:"Follow symbolic links."`
NoArchive bool `short:"n" help:"Disables archive support."`
Print0 bool `name:"print0" short:"0" help:"Use a a null character instead of the newline character, to be used with the -0 option of xargs."`
Print0 bool `name:"print0" short:"0" help:"Use a null character instead of the newline character, to be used with the -0 option of xargs."`
Version bool `short:"V" help:"Show version."`
XWhere string `name:"where" short:"w" help:"(removed) this option has moved to the <where> argument"`
Where string `arg:"" name:"where" optional:"" help:"The filter using sql-where syntax (see -H). Use '-' to skip when providing a path."`
Where string `arg:"" name:"where" optional:"" help:"The filter using SQL-where syntax (see -H). Use '-' to skip when providing a path."`
Paths []string `arg:"" name:"path" optional:"" help:"Paths to search."`
}

Expand Down