我只想列出我的 *.lua 文件并将其编译为 *.ttt 文件。

我只想列出我的 *.lua 文件并将其编译成 *.ttt 文件。

我的 buildData.sh 文件如下:

findLua()
{

for file in $(find $PWD -name "*.lua")
do
    local dirname=$(dirname "$file")
    local filename=$(basename "$file")
    local fuName=$dirname"/"${filename%.*}

    local outPath = $fuName | sed "s/.*Lua\/\(.*\)/\1/"
    echo $fuName | sed "s/.*Lua\/\(.*\)/\1/"  #echo the absolute path is right
    echo $outPath #the echo nothing why?
    $LUACTOOL -o $TEMPDIR$outPath.ttt $file
    echo out$TEMPDIR$outPath.ttt
done
}

这一行:

 local outPath = $fuName | sed "s/.*Lua\/\(.*\)/\1/"

得到的是空值,但我用 $fuName | sed "s/. Lua/(.)/\1/" 进行回显,结果是正确的,为什么会这样?有人能帮我吗?

点赞
用户2235132
用户2235132

你想要将命令的输出存储到一个变量中。使用正确的语法

local outPath=$( echo $fuName | sed "s/.*Lua\/\(.*\)/\1/" )
2013-10-26 10:11:38