Concatenate files from command line with glob pattern.
npm install globcat





Concatenate files in alphabetical order from command line with glob pattern.
``sh`
npm install [--global] globcat
`javascript
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
})
`
- stream Set to true to get a readable stream instead of string in thefalse
callback. Defaults to .glob
- Is passed through to [glob][glob]. For option details please
view the glob package. Thanks glob and minimatch for your excellence! :)
[glob]: https://www.npmjs.com/package/glob
Using CLI arguments:
`sh`
globcat path/.txt other//.txt --output combined.txt
Using pipes:
`sh`
cat file-with-paths.txt | globcat > combined.txt
Oneliner without installing using npx, use --quiet to suppress output fromnpx itself:
`sh`
npx --quiet globcat *.txt > all.txt
To see available options run globcat --help`.