을 촬영하지 함수에서 두 번째 매개 변수 나는 정확히 여기하는 다른 파일에있는 함수에 두 번째 매개 변수를 전달할 수 없습니다 :배쉬 기능 - 어떤 이유로
$lsValidLocal | xargs -n 1 -I {} bash -c 'Push "{}" "**$inFolder**"
푸시 기능에 functions.sh$ inFolder 두 번째 매개 변수를 읽지 않습니다.
나는 여러 가지 방법을 시도, 이제 변수를 수출까지가 전 세계적으로 액세스 할 수 있도록하는 유일한 작업 방법 (아니지만 좋은 해결책)script.sh
#!/bin/bash
#other machine
export otherachine="IP_address_otherachine"
#folders
inFolder="$HOME/folderIn"
outFolder="$HOME/folderOut"
#loading functions.sh
. /home/ec2-user/functions.sh
export lsValidLocal="lsValid $inFolder"
echo $inFolder
#execution
$lsValidLocal | xargs -n 1 -I {} bash -c 'Push "{}" "$inFolder"'
functions.sh
function Push() {
local FILE=$1
local DEST=$2
scp $FILE $otherachine:$DEST &&
rm $FILE ${FILE}_0 &&
ssh $otherachine "touch ${FILE}_0"
}
function lsValid() { #from directory
local DIR=$1
ls $DIR/*_0 | sed 's/.\{2\}$//'
}
export -f Push
export -f Pull
export -f lsValid
'푸시'의 인수를 표시하려고 했습니까? – mouviciel