I have a long Linux csh command that finds/tars/and zips all files in all subdirectories of a directory. It looks like this:
find /dir1/dir2/* -mtime -1 -type -f -print0 | xargs -0 tar -zcf /dir1/dir3/log_archive.tar.gz
I modified it for AIX to look like this (We have both Linux and AIX boxes on our system.):
find /dir1/dir2/* -mtime -1 -type -f -print | xargs tar -cf /dir1/dir3/log_archive.tar
This only creates the tar file since AIX doesn't allow the z(ip) option on the tar command. I'm struggling with adding the zip part to it.
I know I can create a multi line script and will do it if I have to. I'd rather keep it a single executable command so I can add it to crontab as a single line. It works great on Linux.
Pipe the output of tar
to gzip
.
find /dir1/dir2/* -mtime -1 -type -f -print | xargs tar -cf - | gzip > /dir1/dir3/log_archive.tar.gz
-
in place of the output filename means to write the archive to standard output, so you can pipe to another command.