Skip to main content

Command line file search tools

Project description

searchophile

Contains file search functionality, combining find, grep, and sed commands. This package is made platform-independent by using the Python tools refind, greplica, and sedeuce.

Contribution

Feel free to open a bug report or make a merge request on github.

Installation

This project is uploaded to PyPI at https://pypi.org/project/searchophile/

To install, ensure you are connected to the internet and execute: python3 -m pip install searchophile --upgrade

Ensure Python's scripts directory is under the environment variable PATH in order to be able to execute the CLI tools properly from command line.

CLI Tools

The following CLI commands are installed with this package.

  • search : search and display contents of files and optionally replace
  • csearch : calls search with filtering for C/C++ code files (.h, .hpp, .c, .cpp, .cxx, .cc) and output line numbers
  • pysearch : calls search with filtering for Python code files (.py) and output line numbers
  • refind : find clone written in Python
  • greplica : grep clone written in Python
  • sedeuce : sed clone written in Python

Search CLI Help

usage: search [-h] [-s SEARCH_STRING_OPT] [-r] [-i] [-l] [-n] [--whole-word]
              [--no-grep-tweaks] [--show-color | --no-color] [--root ROOT_DIR] [-a NAME]
              [-w PATH] [-x REGEX_NAME] [-e REGEX_PATH] [-M MAX_DEPTH] [-m MIN_DEPTH]
              [--replace REPLACE_STRING] [-t] [--show-errors] [--version] [--dry-run]
              [search_string]

Recursively search for files within a directory

optional arguments:
  -h, --help            show this help message and exit

grep Options:
  search_string         Search for this string in files (as positional)
  -s SEARCH_STRING_OPT, --string SEARCH_STRING_OPT
                        Search for this string in files (as option)
  -r, --regex-search    Search as regex instead of string
  -i, --ignore-case     Ignore case when searching
  -l, --list-file-names
                        List matching file names only for search operation
  -n, --show-line-number
                        Show line number in result
  --whole-word, --wholeword
                        Search with whole word only
  --no-grep-tweaks      Don't make any tweaks to the output of grep
  --show-color          Set to display color in search output (default: auto)
  --no-color            Set to not display color in search output (default: auto)

find options:
  --root ROOT_DIR       Root directory in which to search (default: cwd)
  -a NAME, --name NAME  File name globs used to narrow search
  -w PATH, --wholename PATH, --whole-name PATH, --path PATH
                        Relative file path globs used to narrow search
  -x REGEX_NAME, --regexname REGEX_NAME, --regex-name REGEX_NAME
                        File name regex globs used to narrow search
  -e REGEX_PATH, --regexwholename REGEX_PATH, --regex-whole-name REGEX_PATH,
  --regexpath REGEX_PATH, --regex-path REGEX_PATH
                        Relative file path regex globs used to narrow search
  -M MAX_DEPTH, --maxdepth MAX_DEPTH, --max-depth MAX_DEPTH
                        Maximum find directory depth (default: inf)
  -m MIN_DEPTH, --mindepth MIN_DEPTH, --min-depth MIN_DEPTH
                        Minimum find directory depth (default: 0)

sed options:
  --replace REPLACE_STRING
                        String to replace search string. If --regex is selected, this must be
                        compatible with sed substitute replace string.

other options:
  -t, --silent          Silence information & confirmations generated by this script. If this
                        is specified with replace operation, no output will displayed unless
                        there was an error.
  --show-errors         Show all errors to stderr instead of suppressing
  --version             output version information and exit
  --dry-run, --dryrun   Print equivalent find/grep/sed commands and exit.

All regular expressions must be in "extended" form.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

searchophile-1.0.8.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

searchophile-1.0.8-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file searchophile-1.0.8.tar.gz.

File metadata

  • Download URL: searchophile-1.0.8.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.9

File hashes

Hashes for searchophile-1.0.8.tar.gz
Algorithm Hash digest
SHA256 2a1588524a1a587488cfdc69bf24629cdad25dd413ea37f7dfb17d3961600d1d
MD5 40286184a597e08a0500b08a0547d8c7
BLAKE2b-256 97c299056bcd9a031c51ec6ae39596292edbc7a121618d9bf6efef579ad71c9d

See more details on using hashes here.

File details

Details for the file searchophile-1.0.8-py3-none-any.whl.

File metadata

  • Download URL: searchophile-1.0.8-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.9

File hashes

Hashes for searchophile-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 8a7112af047cccf36ee3582d517f2e7509d4ed3f36aacfce3453323d16d78339
MD5 c8fb4f106d84d73cb29962236ded2128
BLAKE2b-256 434dd44586206f32adbbdde0d85908bc6cd29ec314b7dfdc38be87a9dea42573

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page