Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
selektives Dateilöschen
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Diskussionsforum
View previous topic :: View next topic  
Author Message
Tinitus
Veteran
Veteran


Joined: 20 Sep 2004
Posts: 1754

PostPosted: Mon Aug 07, 2006 3:41 pm    Post subject: selektives Dateilöschen Reply with quote

Hallo,

ich habe aus versehen mehrere Hundert Dateien in einen falschen Ordner kopiert.

Jetzt liegen dort die Dateien und auch noch in dem alten Ordner. Wie kann ich diese ein wenig automatisiert durch abgleichen mit dem alten Ordner wieder löschen ohne diese manuell aussortiren zu müssen?

Mußte als root arbeiten deshalb liegen diese unter /usr



G. R.
Back to top
View user's profile Send private message
SinoTech
Advocate
Advocate


Joined: 20 Mar 2004
Posts: 2579
Location: Neunkirchen / Saarland / Germany

PostPosted: Mon Aug 07, 2006 3:50 pm    Post subject: Reply with quote

Ich gehe mal davon aus das, im Normalfall, im zweiten verzeichniss keine Dateien existieren die den gleichen Namen haben wie Dateien aus dem ersten ordner. In dem Fall sollte folgenedes Script funktionieren:
Code:

#!/bin/bash

DIR1="a"
DIR2="b"

for i in `ls ${DIR1}`
do
        if ls b | grep $i > /dev/null
        then
                echo "Directory ${DIR2} contains a clone of ${i}"
        fi
done

Wobei ...
1. DIR1 und DIR2 durch die entsprechenden Verzeichnisse ersetzt werden muss.
2. Es im Moment nur ausgibt welche Dateien doppelt sind (Das "echo" Statement musst du also durch ein "rm" statement ersetzen).

Einfach mal testen ob es funktoniert und welche Dateien es dir ausspuckt.

Mfg

Sino
_________________
Help to answer the unanswered
Back to top
View user's profile Send private message
think4urs11
Bodhisattva
Bodhisattva


Joined: 25 Jun 2003
Posts: 6659
Location: above the cloud

PostPosted: Mon Aug 07, 2006 4:08 pm    Post subject: Reply with quote

keine klassische Supportfrage, daher Deutsches Forum (German) :arrow: Diskussionsforum.
_________________
Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Diskussionsforum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum