1

i have a script as below :

#!/bin/bash

if [ -z "$1" ]; then
        echo "Missing output folder name"
        exit 1
fi

split -l 10000 --additional-suffix=.ordtmp orders.txt orders

for f in `ls *.ordtmp`; do
        if [ "$2" == "local" ]; then
                mv $f $1
        else
                hdfs dfs -copyFromLocal $f $1
                rm -f $f
        fi
        sleep 3
done

When I try to run it, i get the error as :

(base) 01HW993798:ch06 tcssig$ ./splitAndSend.sh
Missing output folder name

Is the file expecting an output folder to be mentioned at he runtime ?

Sarang Manjrekar
  • 1,839
  • 5
  • 31
  • 61

1 Answers1

5

$1 means an input argument and -z means non-defined or empty

You’re testing whether an input argument to the script was defined when running the script

chananelb
  • 238
  • 1
  • 10