Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A globber for the command line. (Windows/Linux/Banana)

NotificationsYou must be signed in to change notification settings

jochemstoel/glob-cmd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Match files using the patterns the shell uses, like stars and stuff.This is aglob implementation in JavaScript for command line use.

Install globally

If you require() this module, it will return just glob.

npm i glob-cmd -g

Help

A list of all currently possible options.

glob --help
  Usage: glob [options]  Options:    -V, --version                output the version number    -j, --json                   JSON encode matches (default separates by newline)    -s, --delimiter [separator]  Separate matches by delimiter (default separator is newline)    -o, --output [filename]      Write to file (write to stdout by default)    -c, --cwd [directory]        The current working directory in which to search    -n, --nodir                  Do not match directories, only files (Note: to match only directories, simply put a / at the end of the pattern)    -h, --help                   output usage information

Examples

Simplest

List all.js files in current directory.

Command:

glob *.js

Output:

index.jsutils.jscli.jssomeotherstuff.js

JSON

List mp3 files in current directory and JSON encode matches.

Command:

glob --json *.mp3

Output:

[   "01. SIR DRUMSALOT.mp3",   "02. BRAVE.mp3",   "03. WAKE UP FOOL.mp3",   "04. THE FEVER IS GROWING.mp3",   "05. THE LIFE FOR ME.mp3",   "06. MAKE BELIEVE.mp3",   "07. FUNNY KIND OF LOVE.mp3",   "08. WITHOUT YOU.mp3",   "09. RUNNING.mp3",   "10. REALITY.mp3",   "11. IT WILL NOT END.mp3",   "12. SCREW IT.mp3"]

Recursive

List all.js files in all (sub)directories of current directory (c:\codegroundjs).

Command:

glob **/*.js

Outut:

dist/Codeground.jsdist/Codeground.min.jsdist/examples/es5/demo/script.jsdist/examples/es5/script.jsdist/examples/es6/demo/script.jsdist/examples/es6/script.jsdist/examples/fullscreen/demo/script.jsdist/examples/fullscreen/script.jsgulpfile.jssrc/Codeground.jstest/test.js

Delimiter (separator)

Use a delimiter to separate matches. In this case, a semi colon.

Command:

glob --delimiter ; *.mp3

Output:

01. SIR DRUMSALOT.mp3;02. BRAVE.mp3;03. WAKE UP FOOL.mp3;04. THE FEVER IS GROWING.mp3;05. THE LIFE FOR ME.mp3;06. MAKE BELIEVE.mp3;07. FUNNY KIND OF LOVE.mp3;08. WITHOUT YOU.mp3;09. RUNNING.mp3;10. REALITY.mp3;11. IT WILL NOT END.mp3;12. SCREW IT.mp3;

Working directory

List all files, directories and subdirectories innode_modules/codegroundjs.

Command:

glob --cwd "e:/npm/node_modules/codegroundjs" **/*

Output:

_config.ymlassetsassets/codeground-rows.pngassets/codeground.pngbower.jsondistdist/codeground.cssdist/Codeground.jsdist/codeground.min.cssdist/Codeground.min.jsdist/examplesdist/examples/es5dist/examples/es5/demodist/examples/es5/demo/demo.htmldist/examples/es5/demo/script.jsdist/examples/es5/demo/style.cssdist/examples/es5/index.htmldist/examples/es5/script.jsdist/examples/es5/style.cssdist/examples/es6dist/examples/es6/demodist/examples/es6/demo/demo.htmldist/examples/es6/demo/script.jsdist/examples/es6/demo/style.cssdist/examples/es6/index.htmldist/examples/es6/script.jsdist/examples/fullscreendist/examples/fullscreen/demodist/examples/fullscreen/demo/demo.htmldist/examples/fullscreen/demo/script.jsdist/examples/fullscreen/demo/style.cssdist/examples/fullscreen/index.htmldist/examples/fullscreen/script.jsdist/examples/fullscreen/style.cssgulpfile.jspackage.jsonREADME.mdsrcsrc/codeground.csssrc/Codeground.jstesttest/test.js

Match only files/directories

Recursively list only files (no directories) inC:\files and write the results as JSON to found.json

Command:

glob --nodir --json --cwd "c:\files" --output found.json **/*

About

A globber for the command line. (Windows/Linux/Banana)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp