bash - 比较 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
请问有什么想法吗?谢谢
解决方案
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 语法是错误的。
推荐阅读
- javascript - 如何在提交打印pdf之前编码以回显用户帖子值?
- python-3.x - 如何在python中调用远程对象上的方法?
- reactjs - 选择不在条件渲染中工作
- c - 指向整数数组的 C 指针
- json - 如何在一个批次中发送多个 post 请求?
- python - 从 windows 和 linux 的子文件夹导入函数
- javascript - 执行上下文:为什么这个 javascript 代码会有这样的行为?
- php - 无法使用 curl 命令在 php 中解码 json 数据
- sql - 如何替换sql中的约束?
- java - 使用 Jetty 9.4.19 v20190610 设置 Vaadin 10+