首页 > 解决方案 > 比较 hdfs 文件和 unix 文件,得到错误

问题描述

我正在获取syntax error near unexpected token (此代码。它运行良好,直到我把这diff条线放进去:

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

请问有什么想法吗?谢谢

标签: bash

解决方案


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

你的 do/while, if then 语法是错误的。


推荐阅读