A
A
Alexander Semenenko2017-10-25 11:15:41
bash
Alexander Semenenko, 2017-10-25 11:15:41

How to script freenas (freebsd) with tar command?

I have folders in one directory, like 20160426 (year, month, day), I need to place the archives of all such folders in another directory. Each folder has its own archive of the form 20160426.tar.gz
Now I do this with
handles
:
Is it somehow automated? There are other files and directories in the dir1 directory that do not need to be archived, only with dates.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2017-10-25
@semenenko88

Create a script that requires two arguments - what to pack and where to tarring.sh :

#!/usr/bin/env bash

echo Argument provided:$1 $2
echo CMD to execute: tar $2/${1##*/}.tar.gz ${1}

Run:
find /dir1 -type d -regextype posix-extended -regex '.*[0-9]{8}' -exec ./tarring.sh {} dir2 \;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question