Search code examples
apache-pigsh

Apache pig script delete a folder if exists


I want to delete the output folder of the previous execution through the apache pig script. This command works fine.

sh [ -e  /home/LocalPig/test ] && rm -rf /home/LocalPig/test

but if I write

sh OutpuFile=/home/LocalPig/test
sh [ -e OutputFile] && rm -rf OutputFile 

I got the error about OutputFile!

ERROR 2997: Encountered IOException. org.apache.pig.tools.parameters.ParameterSubstitutionException: Undefined parameter : OutputFile

Does anybody have any idea?

Thanks


Solution

  • Reference: Parameter Substituion

    %declare OutputFile '/home/LocalPig/test'
    sh [ -e '$OutputFile' ] && rm -rf '$OutputFile'