Script copie fichier

Fermé
kamax - 13 sept. 2007 à 13:24
lami20j Messages postés 21331 Date d'inscription jeudi 4 novembre 2004 Statut Modérateur, Contributeur sécurité Dernière intervention 30 octobre 2019 - 13 sept. 2007 à 13:44
Bonjour,
je souhaite faire un script qui me permette de copier tous les fichiers d'un répertoire X dans un autre répertoire temporaire. Puis de rendre tous les fichiers et répertoires read-only. Ensuite, de les zipper.
Quelqu'un peut-il m'aider?
A voir également:

1 réponse

lami20j Messages postés 21331 Date d'inscription jeudi 4 novembre 2004 Statut Modérateur, Contributeur sécurité Dernière intervention 30 octobre 2019 3 569
13 sept. 2007 à 13:44
Salut,
root@debian:~# ls -lR X/
X/:
total 8
-rw-r--r-- 1 root lami20j    0 2007-09-13 15:46 a
-rw-r--r-- 1 root lami20j    0 2007-09-13 15:46 b
-rw-r--r-- 1 root lami20j    0 2007-09-13 15:46 c
drwxr-xr-x 2 root lami20j 4096 2007-09-13 15:47 rep1
drwxr-xr-x 2 root lami20j 4096 2007-09-13 15:48 rep2

X/rep1:
total 0
-rw-r--r-- 1 root lami20j 0 2007-09-13 15:47 aa
-rw-r--r-- 1 root lami20j 0 2007-09-13 15:47 bbb

X/rep2:
total 0
-rw-r--r-- 1 root lami20j 0 2007-09-13 15:48 ccc
root@debian:~# ls -l TEMP/
total 0
root@debian:~# cp -R X/* TEMP/
root@debian:~# ls -lR TEMP/
TEMP/:
total 8
-rw-r--r-- 1 root lami20j    0 2007-09-13 15:49 a
-rw-r--r-- 1 root lami20j    0 2007-09-13 15:49 b
-rw-r--r-- 1 root lami20j    0 2007-09-13 15:49 c
drwxr-xr-x 2 root lami20j 4096 2007-09-13 15:49 rep1
drwxr-xr-x 2 root lami20j 4096 2007-09-13 15:49 rep2

TEMP/rep1:
total 0
-rw-r--r-- 1 root lami20j 0 2007-09-13 15:49 aa
-rw-r--r-- 1 root lami20j 0 2007-09-13 15:49 bbb

TEMP/rep2:
total 0
-rw-r--r-- 1 root lami20j 0 2007-09-13 15:49 ccc
root@debian:~# chmod -R 0444 TEMP/
root@debian:~# ls -ld TEMP/
dr--r--r-- 4 root lami20j 4096 2007-09-13 15:49 TEMP/
root@debian:~# ls -lR TEMP/
TEMP/:
total 8
-r--r--r-- 1 root lami20j    0 2007-09-13 15:49 a
-r--r--r-- 1 root lami20j    0 2007-09-13 15:49 b
-r--r--r-- 1 root lami20j    0 2007-09-13 15:49 c
dr--r--r-- 2 root lami20j 4096 2007-09-13 15:49 rep1
dr--r--r-- 2 root lami20j 4096 2007-09-13 15:49 rep2

TEMP/rep1:
total 0
-r--r--r-- 1 root lami20j 0 2007-09-13 15:49 aa
-r--r--r-- 1 root lami20j 0 2007-09-13 15:49 bbb

TEMP/rep2:
total 0
-r--r--r-- 1 root lami20j 0 2007-09-13 15:49 ccc
root@debian:~# zip -r temp.zip TEMP/  
  adding: TEMP/ (stored 0%)
  adding: TEMP/b (stored 0%)
  adding: TEMP/c (stored 0%)
  adding: TEMP/rep2/ (stored 0%)
  adding: TEMP/rep2/ccc (stored 0%)
  adding: TEMP/rep1/ (stored 0%)
  adding: TEMP/rep1/aa (stored 0%)
  adding: TEMP/rep1/bbb (stored 0%)
  adding: TEMP/a (stored 0%)
root@debian:~# ls -l temp.zip
-rw-r--r-- 1 root lami20j 1174 2007-09-13 15:51 temp.zip
root@debian:~#

En gras tu as les commandes
0