summaryrefslogtreecommitdiffstats
path: root/aiaiai-concat-mboxes
blob: 8de22eb1a6b216dfef523e64e51423a13b47dee5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh -efu

# Copyright 2012 Intel Corporation
# Author: Artem Bityutskiy
# License: GPLv2

srcdir="$(readlink -ev -- ${0%/*})"
PATH="$srcdir:$srcdir/helpers/libshell:$PATH"

. shell-error

PROG="${0##*/}"

show_usage()
{
	cat <<-EOF
Usage: $PROG <mbox_files>

<mbox_files> - a list of mbox files to concatenate.

This is a simple script which concatenates several mbox files into one. The
resulting mbox is printed to stdout.

Note, using just "cat" to contatenate the files is not going to produce a
correct mbox because there won't be the required blank line between the e-mails
in the resulting mbox.
EOF
}

fail_usage()
{
	[ -z "$1" ] || printf "%s\n" "$1"
	show_usage
	exit 1
}

[ "$#" -gt 0 ] || fail_usage 'Please, specify at least one file'

while [ "$#" -ge 2 ]; do
	cat "$1"
	printf "\n"
	shift
done

cat "$1"