Mailinglist Archive: opensuse (1264 mails)

< Previous Next >
Re: [opensuse] Quick question: how to call a script function from "find"? - using parallel
  • From: Vojtěch Zeisek <vojtech.zeisek@xxxxxxxxxxxx>
  • Date: Wed, 14 Jun 2017 15:42:12 +0200
  • Message-id: <1888247.4EIFHRmH6o@tilia>
Dne středa 14. června 2017 15:28:47 CEST, Carlos E. R. napsal(a):
On 2017-06-14 14:47, Vojtěch Zeisek wrote:
Dne středa 14. června 2017 14:25:59 CEST, Carlos E. R. napsal(a):
On 2017-06-14 13:53, Per Jessen wrote:
Carlos E. R. wrote:
find /home/cer/Fusion/Videos/ -type d | parallel parallel "sudo chown
Type: 'will cite' and press enter.

Run 'parallel --bibtex' just once.

I did. It said I would not get nagged again, but it is false.

Weird. I use it very often on various computers, no problem like this.

This is the script now:

#!/bin/bash

find /home/cer/Fusion/Videos/ -type d | parallel --bibtex "sudo chown
cer:cer '{}' && chmod u+r+w+x,g+w+x,o+r-w-x,+t '{}'' && sudo chown
cer-g:cer '{}' && sudo setfacl -m u:wwwrun:rx '{}'"

Wrong. Use:

sudo echo
find /home/cer/Fusion/Videos/ -type d | parallel --bibtex "sudo chown cer:cer
''{}'' && chmod u+r+w+x,g+w+x,o+r-w-x,+t ''{}'' && sudo chown cer-g:cer ''{}''
&& sudo setfacl -m u:wwwrun:rx ''{}''"

Usually (I try to keep only a-zA-Z0-9, minus and undescore for file/dir names
and then only '{}' is sufficient. If the expansion would contain characters
like spaces, apostrophes or brackets, there apparently must be double quoting
like ''{}''. It is also required for some exotic argument. Like one program I
use takes parameters like "QD < 2". It must be quoted within parallel.

So now I remove the "--bibtex" thing, and I get this instead:

cer@Isengard:~/Fusion> time ./_Cambiar_permisos_Videos
chown: cannot access '/home/cer/Fusion/Videos/Buffy,\ cazavampiros': No such
file or directory chown: cannot access '/home/cer/Fusion/Videos/Major\
Crimes': No such file or directory chown: cannot access
'/home/cer/Fusion/Videos/Buffy,\ cazavampiros/Temporada\ 7': No such file
or directory chown: cannot access '/home/cer/Fusion/Videos/Major\
Crimes/Temporada\ 5': No such file or directory chown: cannot access
'/home/cer/Fusion/Videos/La\ Casa\ de\ Papel': No such file or directory
chown: cannot access '/home/cer/Fusion/Videos/La\ Casa\ de\
Papel/Temporada\ 1': No such file or directory chown: cannot access
'/home/cer/Fusion/Videos/Crossing\ Jordan': No such file or directory
chown: cannot access '/home/cer/Fusion/Videos/Crossing\ Jordan/Temporada\
2': No such file or directory chown: cannot access
'/home/cer/Fusion/Videos/Crossing\ Jordan/Temporada\ 1': No such file or
directory chown: cannot access '/home/cer/Fusion/Videos/Ley\ y\ orden\ \
unidad\ de\ victimas\ especiales': No such file or directory chown: cannot
access '/home/cer/Fusion/Videos/Ley\ y\ orden\ \ unidad\ de\ victimas\
especiales/Temporada\ 13': No such file or directory chown: cannot access
'/home/cer/Fusion/Videos/Ley\ y\ Orden\ \ Unidad\ de\ Victimas\
Especiales': No such file or directory chown: cannot access
'/home/cer/Fusion/Videos/Ley\ y\ orden\ \ unidad\ de\ victimas\
especiales/Temporada\ 14': No such file or directory chown: cannot access
'/home/cer/Fusion/Videos/Ley\ y\ Orden\ \ Unidad\ de\ Victimas\
Especiales/Temporada\ 13': No such file or directory chown: cannot access
'/home/cer/Fusion/Videos/Justified\ \ la\ ley\ de\ Raylan': No such file or
directory chown: cannot access '/home/cer/Fusion/Videos/Justified\ \ la\
ley\ de\ Raylan/Temporada\ 6': No such file or directory ^C

The quotes from Your above command was wrong (see above).

So I change the script to:

find /home/cer/Fusion/Videos/ -type d | parallel "sudo chown cer:cer {} &&
chmod u+r+w+x,g+w+x,o+r-w-x,+t {} && sudo chown cer-g:cer {} && sudo
setfacl -m u:wwwrun:rx {} "

I don't like to run it without quotes.

and this finally runs!

cer@Isengard:~/Fusion> time ./_Cambiar_permisos_Videos

real 0m3.881s
user 0m8.909s
sys 0m1.916s
cer@Isengard:~/Fusion>

There is some speed improvement.

The bigger task, the bigger difference...

--
Vojtěch Zeisek
https://trapa.cz/
< Previous Next >