globcat
v3.1.1
Published
Concatenate files from command line with glob pattern.
Maintainers
Readme
globcat
Concatenate files in alphabetical order from command line with glob pattern.
Install
npm install [--global] globcatUsage
import globcat from 'globcat'
const options = {
/*...*/
}
// just the one...
globcat('**/*.txt', (err, contents) => {
// contents contains the file contents of the matched files
// err is an error object or null
})
// ... or with array
globcat(['path/to/file.txt', 'other/path/*.txt'], options, (err, contents) => {
// contents contains the file contents of the matched files
// err is an error object or null
})
// as promise
globcat(['path/to/file.txt', 'other/path/*.txt'], options)
.then(function (contents) {
// use contents
})
.catch(function (err) {
// handle error
})Options
streamSet totrueto get a readable stream instead of string in the callback. Defaults tofalse.globIs passed through to glob. For option details please view the glob package. Thanks glob and minimatch for your excellence! :)
Command Line
Using CLI arguments:
globcat path/*.txt other/**/*.txt --output combined.txtUsing pipes:
cat file-with-paths.txt | globcat > combined.txtOneliner without installing using npx, use --quiet to suppress output from
npx itself:
npx --quiet globcat *.txt > all.txtTo see available options run globcat --help.
