L
L
LakeForest2021-09-20 14:32:33
linux
LakeForest, 2021-09-20 14:32:33

How to archive 70 files from one directory to different archives?

I tried so that through tail -n 70 then skip 70, but:

$ls -l -t test/ | head -70 | tar -cvf archive_2_70.tar.gz
tar: Cowardly refusing to create an empty archive

There are 210 files in the directory.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
SOTVM, 2021-09-20
@LakeForest

for tar pass through xargs , not pipe ))

P
pfg21, 2021-09-20
@pfg21

in a pipe there is no way to transfer several separate files / sets of names
. First, you cut your listing into separate files with 70 names in each. you throw it into a frame so as not to force the carrier.

ls -l -t test/ |  split -l 70 -  /run/user/1000/list

there will be a bunch of files called listaa listab ....
then you feed these separate lists of names already tar
for file in /run/user/1000/list*
do
      i++
      tar  --files-from=$file  -cvf  /path/to/archive_$i_70.tar.gz 
done

you will get a pack of tar-archives in each of which there will be 70 files from the source directory.
exemplary scripts, finish in place.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question