A one-liner using a conditional is as close as you can come.
cd /path/to/output && split --bytes=1024M /path/to/input/filename && gzip x*
gzip
will only run if split
is successful because of the conditional &&
which is also between the cd
and split
making sure the cd
is successful, too.. Note that split
and gzip
output to the current directory instead of having the ability to specify the output directory. You can make the directory, if needed:
mkdir -p /path/to/output && cd /path/to/output && split --bytes=1024M /path/to/input/filename && gzip x*
To put it all back together:
gunzip /path/to/files/x* && cat /path/to/files/x* > /path/to/dest/filename