concat.sh is a bash script that allows you to concatenate text files from a directory into a single output file. It provides several options to control the inclusion and exclusion of files, line filtering, and output file management.
- Concatenate all text files from a directory into a single output file.
- Exclude specific files or directories from being processed.
- Skip empty files during the concatenation process.
- Filter lines in the files using a regular expression pattern.
- Easily specify the input directory and output file.
-
Clone this repository to your local machine:
git clone https://github.com/yourusername/concat.sh.git
-
Navigate to the directory:
cd concat.sh -
Make the script executable:
chmod +x concat.sh
./concat.sh [OPTIONS]-
-i, --input DIR
Specify the input directory (default: current directory). -
-o, --output FILE
Specify the output file (default:res.txtin the current directory). -
-s, --skipEmpty
Skip empty files after processing. -
-e, --exclude DIR
Exclude specified directories or files (can be used multiple times). -
-er, --excludeRegex REGEX
Exclude lines matching the given regex pattern. -
-h, --help
Show this help message and exit.
-
Concatenate files, excluding empty files, directories, and using regex:
./concat.sh -i ./somePath -o output.txt -s -e ./dist ./node_modules -er '^import .*;'This will concatenate all files in
somePath, excluding empty files,dist, andnode_modules, removing lines starting withimport, and write the output tooutput.txt. -
Concatenate files from a log directory, skipping empty files and removing lines containing "DEBUG":
./concat.sh -i ./logs -s -er 'DEBUG'This will concatenate all files in the
logsdirectory, skip empty files, and remove lines containing the string "DEBUG".
This project is licensed under the MIT License. See the LICENSE file for more information.