Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hi Leute,

habe als kleine Uebungsaufgabe verschiedene Files (bei mir .core) rekursiv in meinem Homeverzeichniss zu suchen und zu löschen.

habe folgendes Skript entwickelt


for i in find ~/Uebung \*.core
do
rm $i 2> /dev/null
done
[/PHP]

auf Ordnerebene auf der das Skript ausgeführt wird funktioniert es tadellos jedoch fehlt der rekursive Durchgang. Im Internet habe ich mich informiert und da heißt es das FIND standartmäßig rekursiv arbeitet.

jedoch löscht er Dateien nicht wenn sie unterhalb von ~/Uebung liegen =(

hoffe ihr könnt mir bei diesem dämlichen Problem helfen.

Gruß Freeed

Hallo,

so wie du find aufrufst, kann das gar nicht funktionieren!

versuchs mal mit

find ~/Uebung -name "*.core"

Und wenn was nicht funktioniert ist es ratsam, nicht die Fehler wegzufiltern ;-)

Hi,

du musst Backticks benutzen, wenn du möchtest dass die Ausgabe eines Befehls als Parameter oder Variable genutzt werden kann:


for i in `find ~/Uebung *.core`

do

   rm $i 2> /dev/null

done  

Vorsicht: Bei einem rm Befehl würde ich mir immer vorher die Ausgabe anzeigen lassen, damit du auch genau weisst was er löscht.

man find

UNIX man pages : find ()

ACTIONS

-delete

Delete files; true if removal succeeded. If the removal failed,

an error message is issued. Use of this action automatically

turns on the '-depth' option.

-exec command ;

Execute command; true if 0 status is returned. All following

arguments to find are taken to be arguments to the command until

an argument consisting of ';' is encountered. The string '{}'

is replaced by the current file name being processed everywhere

it occurs in the arguments to the command, not just in arguments

where it is alone, as in some versions of find. Both of these

constructions might need to be escaped (with a '\') or quoted to

protect them from expansion by the shell. See the EXAMPLES sec-

tion for examples of the use of the '-exec' option. The speci-

fied command is run once for each matched file. The command is

executed in the starting directory. There are unavoidable

security problems surrounding use of the -exec option; you

should use the -execdir option instead.

Hi,

ähem, ja, die Syntax ist natürlich auch noch wichtig. Denn wenn du meine Version des Skriptes jetzt 1:1 so kopiert und ausgeführt hättest, kannst du nur hoffen dass du ein Backup von dem System hast. :)

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.