[英]Executing hadoopfs in shell script
I trying to run a bash script of the following : 我试图运行以下的bash脚本:
#!/bin/bash
CURRENT_HDFS_PATH=`hadoopfs -ls -t -r /$CLEAN_HDFS_PATH | tail -1 | awk -F ' ' '{print $8}'`
echo "Here is the last (most current) file in the history folder to be downloaded=$CURRENT_HDFS_PATH"
The above does not produce any result at all. 以上内容根本不会产生任何结果。 Please note that CLEAN_HDFS_PATH=/temp/local-*.inprogress 请注意CLEAN_HDFS_PATH = / temp / local - *。inprogress
When I use the following in command line: 当我在命令行中使用以下内容时:
hadoopfs -ls -t -r '/temp/local-*.inprogress' | tail -1 | awk -F ' ' '{print $8}'
I get the answer from the command line. 我从命令行得到了答案。
What am I doing wrong in my script ? 我的剧本中我做错了什么?
Cheers, 干杯,
Is the name of the file literally local-*.inprogress
? 该文件的名称是字面上的local-*.inprogress
? If so, your problem is wildcard expansion within script. 如果是这样,您的问题是脚本中的通配符扩展。 Add double quotes around the variable and see if that works like: 在变量周围添加双引号,看看它是否有效:
CURRENT_HDFS_PATH=`hadoopfs -ls -t -r "/$CLEAN_HDFS_PATH" | tail -1 | awk -F ' ' '{print $8}'`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.