A
A
Alexander F2019-11-14 22:40:41
bash
Alexander F, 2019-11-14 22:40:41

How to edit the output of the find command?

Hello. I am learning Linux.
Playing around with the Find command. I decided to try the task of creating Cron archives.
I want all Cron directories to be placed in the archive and in the /backup folder. I
came up with this script:
#!/bin/bash
cd /etc
find . -maxdepth 1 -name 'cron*' -type d -exec tar cf /etc/backup/{}.tar.gz {} \;
BUT!
It turns out that the archive is created along this path /etc/backup/./cron.monthly.tar.gz, but it should be /etc/backup/cron.monthly.tar.gz. How to do it? How to remove this extra nesting?
It looks like the answer is somewhere on the surface, but I can not find (((

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2019-11-14
@lex63

the archive is created along this path /etc/backup/./cron.monthly.tar.gz, but it is necessary along this path /etc/backup/cron.monthly.tar.gz.

It's the same path written in different ways, what's the problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question