GNU Parallel-und Bash-Funktionen: so führen Sie das einfache Beispiel aus dem Handbuch

Ich versuche zu lernen, GNU Parallel, weil ich habe einen Fall, wo ich denke, ich könnte leicht parallelisieren, eine bash-Funktion. Also versuchen zu lernen, ging ich zu der GNU Parallel Handbuch wo es ein Beispiel...aber ich kann nicht sogar arbeiten! Zu Witz:

(232) $ bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
(233) $ cat tpar.bash
#!/bin/bash

echo `which parallel`
doit() {
  echo Doing it for $1
  sleep 2
  echo Done with $1
}
export -f doit
parallel doit ::: 1 2 3
doubleit() {
  echo Doing it for $1 $2
  sleep 2
  echo Done with $1 $2
}
export -f doubleit
parallel doubleit ::: 1 2 3 ::: a b

(234) $ bash tpar.bash
/home/mathomp4/bin/parallel
doit: Command not found.
doit: Command not found.
doit: Command not found.
doubleit: Command not found.
doubleit: Command not found.
doubleit: Command not found.
doubleit: Command not found.
doubleit: Command not found.
doubleit: Command not found.

Wie Sie sehen können, kann ich nicht mal das einfache Beispiel, um zu laufen. So, ich bin wohl etwas zu tun erstaunlich dumm und basic...aber ich bin ratlos.

ETA: Wie vorgeschlagen, durch Kommentatoren (chmod +x, set-vx):

(27) $ ./tpar.bash

echo `which parallel`
which parallel
++ which parallel
+ echo /home/mathomp4/bin/parallel
/home/mathomp4/bin/parallel

doit() {
  echo Doing it for $1
  sleep 2
  echo Done with $1
}
export -f doit
+ export -f doit
parallel doit ::: 1 2 3
+ parallel doit ::: 1 2 3
doit: Command not found.
doit: Command not found.
doit: Command not found.
doubleit() {
  echo Doing it for $1 $2
  sleep 2
  echo Done with $1 $2
}
export -f doubleit
+ export -f doubleit
parallel doubleit ::: 1 2 3 ::: a b
+ parallel doubleit ::: 1 2 3 ::: a b
doubleit: Command not found.
doubleit: Command not found.
doubleit: Command not found.
doubleit: Command not found.
doubleit: Command not found.
doubleit: Command not found.

ETA2: Anmerkung, ich kann in dem script, nur call 'doit-1', sagen Sie, und es wird das tun. So wird die Funktion gültig ist, ist es eben nicht...exportiert?

  • Sind Sie sicher, dass Sie GNU parallel, und nicht die version von Tollef Fog Heen?
  • Es ist GNU parallel: (247) $ parallel --version GNU parallel 20140522
  • Ich habe versucht. Gleiche Antwort.
  • Es funktioniert gut auf meinem Mac unter OSX. Haben Sie tpar.bash ausführbare Datei mit chmod +x tpar.bash
  • Hilft es, wenn Sie hinzufügen function vor doit(){
InformationsquelleAutor Fortran | 2014-05-22
Schreibe einen Kommentar