- Notifications
You must be signed in to change notification settings - Fork0
jochemstoel/glob-cmd
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
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.
If you require() this module, it will return just glob.
npm i glob-cmd -g
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
List all.js files in current directory.
Command:
glob *.js
Output:
index.jsutils.jscli.jssomeotherstuff.js
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"]
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
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;
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
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 **/*