Skip to content

Instantly share code, notes, and snippets.

@kallmanation
Last active May 28, 2019 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kallmanation/8f26464cadfa3eaeaf2c3c3b0f7e4918 to your computer and use it in GitHub Desktop.
Save kallmanation/8f26464cadfa3eaeaf2c3c3b0f7e4918 to your computer and use it in GitHub Desktop.
A simple file-driven concatenation command
#!/bin/bash
catdeck() {
if [[ "$#" -eq 0 ]]; then
(>&2 echo "usage: $0 final_file_name.catdeck")
exit 1
fi
OUTPUTFILE=$(echo "$1" | sed 's/\.catdeck//')
echo -n "" > "$OUTPUTFILE"
for FILE in `cat "$1"`; do
2>/dev/null cat "$FILE" >> "$OUTPUTFILE" || echo "$FILE" >> "$OUTPUTFILE"
done
}
catdeck "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment