Angus
Angus

Reputation: 167

Compare hdfs file with unix file, getting error

I'm getting syntax error near unexpected token ( for this code. It runs fine until I put the diff line in it:

shopt -s nullglob
for f in *.csv
  hdfs dfs -test -e $target_dir/$f
  if [ $? = 0 ]
  then
    echo File exists. check if its same hadoop v unix
    if diff <(hdfs dfs -cat $target_dir/$f) <(cat $f)
    then
      echo Files are the same
    fi
  fi
done

Any ideas please? Thanks

Upvotes: 0

Views: 48

Answers (1)

apatniv
apatniv

Reputation: 1856

for f in *.csv; do
  hdfs dfs -test -e "$target_dir/$f"
  rc=$?
  if [[ "$rc" == 0 ]]; then
    echo "File exists. check if its same hadoop v unix"
    if diff <(hdfs dfs -cat "$target_dir/$f") <(cat "$f") ; then
      echo "Files are the same"
    fi
  fi
done

Your do/while, if then syntax is wrong.

Upvotes: 1

Related Questions