0

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,449
  • 3
  • 25
  • 57

1 Answers1

2

$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
  • 208
  • 1
  • 8