Code: Alles auswählen
/var/www/virtual/website.tld/example.jpg
/var/www/virtual/website.tld/example.php
...
Ich will nicht automatisch gleich alle Dateien ändern, sondern die Liste abarbeiten (wird vorher gecheckt) es gibt ein paar Ausnahmen ...
Code: Alles auswählen
/var/www/virtual/website.tld/example.jpg
/var/www/virtual/website.tld/example.php
...
man find hat geschrieben: -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 section
for examples of the use of the -exec option. The specified 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 action; you should use the -execdir option instead.
Sowas?fulltilt hat geschrieben:ist es möglich die gefundenen Dateien aus dieser Liste auf einen Schlag auf 644 zu setzen?
Code: Alles auswählen
while read -r line;do chmod 0644 $line;done < datei.txt
fulltilt hat geschrieben:habe vorhin mal einen file permission check ausgeführt und in eine datei ausgegeben
Code: Alles auswählen
vi datei
Code: Alles auswählen
:%s/^/chmod 644 /g
:wq
Danke, ja das müsste klappen ... ich teste maltobo hat geschrieben:Sowas?fulltilt hat geschrieben:ist es möglich die gefundenen Dateien aus dieser Liste auf einen Schlag auf 644 zu setzen?Code: Alles auswählen
while read -r line;do chmod 0644 $line;done < datei.txt
Brauch man garkeinen vi(m) dafür, geht mit sed auch:MSfree hat geschrieben:Code: Alles auswählen
vi date
Code: Alles auswählen
:%s/^/chmod 644 /g :wq
Code: Alles auswählen
cat /path/to/file|sed -e 's/^/chmod 644 /'|sh -
Stimmt, aber mit dem sed kannst du nicht die oben erwähnten Ausnahmen rauseditieren.sbruder hat geschrieben:Brauch man garkeinen vi(m) dafür, geht mit sed auch:Code: Alles auswählen
cat /path/to/file|sed -e 's/^/chmod 644 /'|sh -
Code: Alles auswählen
<files.txt xargs -d \\n chmod 644
Ups - ja, das ist natürlich richtig und auch wichtig!Meillo hat geschrieben:Beim while-read-Schleifen-Vorschlag sollte man die Variablenexpansion unbedingt Quoten (das funktioniert auch korrekt wenn im Namen selbst Quotes enthalten sind). Bei solchen Befehlen sollte man wirklich dran denken Variablenexpansionen in Double-Quotes zu setzen.