|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Senior Member
Iscritto dal: Dec 2004
Messaggi: 3573
|
rm: come eliminare tutti i files all'interno di una directory?
L'ho già chiesto altre volte in altri topic, ma nessuno ha mai saputo rispondermi. Badate bene che non voglio eliminare le directory, ma solo i files.
La domanda può sembrare delle più stupide, ma non è poi così banale: con un rm * infatti non vengono eliminati i files nascosti, per i quali è necessario un rm .* (ma in questo caso vengono eliminati SOLO i file nascosti). Tra l'altro con quest'ultimo comando mi tocca reindirizzare l'stderr su /dev/null, perché rm ha l'accortezza di farmi notare che: rm: impossibile rimuovere la directory `.' rm: impossibile rimuovere la directory `..' ![]() Ho provato a giocare con i caratteri jolly (rm ?*) o ad utilizzare la ricorsione (non si sa mai ![]() ![]() Vale la stessa cosa per l'amico cp ![]() Come fare? Non ditemi di creare uno script da mettere nel path perché non la ritengo una soluzione.
__________________
Debian amd64 | Gentoo amd64 | AMD Athlon64 3800+ X2@2701Mhz vcore 1.49V | Placing an unpatched Windows computer directly onto the Internet in the hope that it downloads the patches faster than it gets exploited are odds that you wouldn't bet on in Vegas | e-mail+jabber: darkbasic|a.t|linuxsystems|d.o.t|it | www.linuxsystems.it |
![]() |
![]() |
![]() |
#2 |
Senior Member
Iscritto dal: Apr 2003
Città: Roma
Messaggi: 1996
|
rm -rf cartella/*
__________________
That was a love song. This is a love song too. It's called: Rocking Hole - Yeah, yeah, yeah. [Last.fm] ~ [Okiwii.net] ~ [Anobii] ~ [Facebook] Ultima modifica di Hire : 23-01-2008 alle 22:42. |
![]() |
![]() |
![]() |
#3 |
Senior Member
Iscritto dal: Mar 2005
Città: Morimondo city
Messaggi: 5491
|
Ma scusa l'ha scritto nel post che non funziona
__________________
Khelidan |
![]() |
![]() |
![]() |
#4 |
Senior Member
Iscritto dal: Nov 2002
Città: Morio Cho
Messaggi: 2592
|
Quindi vuoi eliminare tutti i file nella directory foo/ ma non le directory, e non ricorsivamente?
Cioè: Codice:
$ mkdir --parent foo/bar $ touch foo/{.,}test1 $ touch foo/bar/{.,}test2 $ find foo/ -maxdepth 1 -type f -exec rm --verbose {} \; `foo/test1' rimosso `foo/.test1' rimosso $ ls -RA foo/ foo/: bar foo/bar: test2 .test2 $ EDIT: se vuoi eliminare tutti i file, ricorsivamente, basta che togli l'opzione "-maxdepth 1".
__________________
Sono GULDO, non Guido! Cioè, certo che guido... Bé, insomma, avete capito ![]() Linux 2.6.26|Debian|Debian@Hwupgrade|Debian Clan|Solo Puffin ti darà forza e grinta a volontà! NERD rank 62|Milla Jovovich|大事な物はいつも形の無い物だけ Sito e Forum sul Giappone|La mia libreria su aNobii Ultima modifica di guldo76 : 23-01-2008 alle 23:38. |
![]() |
![]() |
![]() |
#5 |
Senior Member
Iscritto dal: Apr 2003
Città: Roma
Messaggi: 1996
|
Ho fatto il test e funziona, sia con files normali che nascosti. Comprese le cartelle, ovviamente
![]()
__________________
That was a love song. This is a love song too. It's called: Rocking Hole - Yeah, yeah, yeah. [Last.fm] ~ [Okiwii.net] ~ [Anobii] ~ [Facebook] |
![]() |
![]() |
![]() |
#6 | |
Senior Member
Iscritto dal: Aug 2007
Messaggi: 1270
|
Non mi ero mai accorto che con rm -rf * i file nascosti non venivano cancellati.
![]() Cosi invece funziona: rm -rf .* * Quote:
Ultima modifica di arara : 24-01-2008 alle 10:39. |
|
![]() |
![]() |
![]() |
#7 | |
Senior Member
Iscritto dal: Apr 2003
Città: Roma
Messaggi: 1996
|
Quote:
![]() Sennò si può fare rm -rf .* * Solo che da un warning perchè non riesce a cancellare le cartell . e .. ![]()
__________________
That was a love song. This is a love song too. It's called: Rocking Hole - Yeah, yeah, yeah. [Last.fm] ~ [Okiwii.net] ~ [Anobii] ~ [Facebook] Ultima modifica di Hire : 24-01-2008 alle 11:29. |
|
![]() |
![]() |
![]() |
#8 | |
Senior Member
Iscritto dal: Oct 2001
Messaggi: 11471
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#9 | |
Senior Member
Iscritto dal: Mar 2005
Città: Morimondo city
Messaggi: 5491
|
Quote:
![]()
__________________
Khelidan |
|
![]() |
![]() |
![]() |
#10 | |
Senior Member
Iscritto dal: Dec 2004
Messaggi: 3573
|
Quote:
Sembra che l'unica sia "rm .* *" con conseguente output-monnezza ![]() rm .* * 2> /dev/null non darebbe niente in output, ma è scomodo da scrivere e ti priva di eventuali output utili.
__________________
Debian amd64 | Gentoo amd64 | AMD Athlon64 3800+ X2@2701Mhz vcore 1.49V | Placing an unpatched Windows computer directly onto the Internet in the hope that it downloads the patches faster than it gets exploited are odds that you wouldn't bet on in Vegas | e-mail+jabber: darkbasic|a.t|linuxsystems|d.o.t|it | www.linuxsystems.it |
|
![]() |
![]() |
![]() |
#11 | |
Senior Member
Iscritto dal: Dec 2004
Messaggi: 3573
|
Quote:
![]()
__________________
Debian amd64 | Gentoo amd64 | AMD Athlon64 3800+ X2@2701Mhz vcore 1.49V | Placing an unpatched Windows computer directly onto the Internet in the hope that it downloads the patches faster than it gets exploited are odds that you wouldn't bet on in Vegas | e-mail+jabber: darkbasic|a.t|linuxsystems|d.o.t|it | www.linuxsystems.it |
|
![]() |
![]() |
![]() |
#12 | ||
Senior Member
Iscritto dal: Nov 2002
Città: Morio Cho
Messaggi: 2592
|
Quote:
Non l'avevo notato, nella pagina man. ![]() Quote:
![]() L'unica istruzione che devi eseguire tu è (grazie VICIUS): Codice:
$ find foo/ -maxdepth 1 -type f -delete
__________________
Sono GULDO, non Guido! Cioè, certo che guido... Bé, insomma, avete capito ![]() Linux 2.6.26|Debian|Debian@Hwupgrade|Debian Clan|Solo Puffin ti darà forza e grinta a volontà! NERD rank 62|Milla Jovovich|大事な物はいつも形の無い物だけ Sito e Forum sul Giappone|La mia libreria su aNobii |
||
![]() |
![]() |
![]() |
#13 | |
Senior Member
Iscritto dal: Dec 2004
Messaggi: 3573
|
Quote:
![]() Ammetto che quando ho visto il papier ho subito pensato allo script ![]() ![]()
__________________
Debian amd64 | Gentoo amd64 | AMD Athlon64 3800+ X2@2701Mhz vcore 1.49V | Placing an unpatched Windows computer directly onto the Internet in the hope that it downloads the patches faster than it gets exploited are odds that you wouldn't bet on in Vegas | e-mail+jabber: darkbasic|a.t|linuxsystems|d.o.t|it | www.linuxsystems.it |
|
![]() |
![]() |
![]() |
#14 |
Senior Member
Iscritto dal: Apr 2003
Città: Roma
Messaggi: 1996
|
Per cancellare le cartelle, si
![]()
__________________
That was a love song. This is a love song too. It's called: Rocking Hole - Yeah, yeah, yeah. [Last.fm] ~ [Okiwii.net] ~ [Anobii] ~ [Facebook] |
![]() |
![]() |
![]() |
#15 |
Senior Member
Iscritto dal: Dec 2004
Messaggi: 3573
|
In quel caso allora * è superfluo. Ovviamente era riferito allo scopo che mi prefiggevo: eliminare tutti i files, nascosti e non.
__________________
Debian amd64 | Gentoo amd64 | AMD Athlon64 3800+ X2@2701Mhz vcore 1.49V | Placing an unpatched Windows computer directly onto the Internet in the hope that it downloads the patches faster than it gets exploited are odds that you wouldn't bet on in Vegas | e-mail+jabber: darkbasic|a.t|linuxsystems|d.o.t|it | www.linuxsystems.it |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 01:28.