Hi all,
I have a problem where i have several files in a directory which I SCP from a server to my local machine and i would like to periodically tar/gzip them based on their naming convention.
Here is the scenario:
I SCP files (which all end with the same ending) periodically across to a '/stored' location:
stat_t_123
stat_p_123
stat_c_123
stat_t_999
stat_p_999
stat_c_999
As you can see they all end in '123' or '999' (as an example).
So what I'm looking for is a way to query the '/stored' directory and look for all files ending with '123' or '999' and then grouping them together into a single tar/gzip'd file.
the tarred files will then remain in the '/stored' location.
So you would end up with:
/stored/files123.tar.gz
/stored/files999.tar.gz
I know i can get all files which are not tars or gzips like this:
`ls /stored | grep -v ".tar" | grep -v ".tar.gz"`
but how would i achieve the grouping?
any helps guys?