Install latest/stable of ls-having
Ubuntu 16.04 or later?
Make sure snap support is enabled in your Desktop store.
ls-having
is a powerful open-source tool that makes it easy to find directories. With a simple and intuitive command-line interface, "ls-having" allows you to quickly search for directories based on specified flag files and other conditions, saving you time and effort. Whether you're a developer who works with mono repos, or you just need an easy way to find your directories, "ls-having" is the perfect tool for you.
Quick start
Try this:
ls-having -f package.json
This will search for directories containing a "package.json" file in the current directory and print the names of those directories to the console. You can then use the output of "ls-having" as arguments for other commands, such as "xargs", to perform actions on those directories.
For more information on how to use "ls-having" and the available options and arguments, visit https://github.com/handy-common-utils/ls-having or run the ls-having --help
command.
Usage
Usage: ls-having -f name-or-glob [options] [root-dir]
Options:
-c, --check-file name name of the additional file to check
-i, --check-inverse regard regular expression not matching as positive
-e, --check-regexp expression regular expression for testing the content of the check file (default ".*")
-d, --depth int how deep to look into subdirectories, 0 means only look at root directory, -1 means no limit (default 5)
-r, --error string how to handle errors such like non-existing directory, no access permission, etc. (ignore|panic|print) (default "ignore")
-x, --exclude glob glob of the directories to exclude, this option can appear multiple times
-f, --flag-file glob name or glob of the flag file, this option can appear multiple times
-h, --help show help information
-a, --match-all-flag-files require all (instead of any) of the flag file names/globs to be matched
-n, --no-default-excludes don't apply default excludes
-0, --print0 separate paths in the output with null characters (instead of newline characters)
-s, --subdirectories-only don't return root directory even if it meets conditions
References:
Glob syntax: https://github.com/gobwas/glob#example
Regexp syntax: https://pkg.go.dev/regexp/syntax
Home page: https://github.com/handy-common-utils/ls-having
Examples
Find all directories in ./
having package.json
file,
and run npm audit fix
in them one by one:
ls-having -f package.json | xargs -I {} bash -c 'cd "{}"; npm audit fix'
Find all directories in ./
having package.json
file
and the package.json
file does not contain "volta":
:
ls-having -c package.json -i -e '"volta":'
Find all directories in ./
having cdk.json
file
and the package.json
file in the directory has mocha
specified as a dependency,
then for each of those directories reinstall latest version of mocha
as dev-dependency:
ls-having -f cdk.json -c package.json -e '"dependencies":\s*{[^{}]*"mocha":' | xargs -I {} bash -c 'cd {}; npm i -D mocha@latest'
Find all directories in ~/myrepo1
having build.gradle
file and a sibling directory australia
:
ls-having -f build.gradle -c ../australia ~/myrepo1
Thank you for your report. Information you provided will help us investigate further.
There was an error while sending your report. Please try again later.
You are about to open
Do you wish to proceed?
Generate an embeddable card to be shared on external websites.
Choose your Linux distribution to get detailed installation instructions. If yours is not shown, get more details on the installing snapd documentation.