Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将目录名存储在bash脚本中变量的路径中_Bash_Hdfs - Fatal编程技术网

将目录名存储在bash脚本中变量的路径中

将目录名存储在bash脚本中变量的路径中,bash,hdfs,Bash,Hdfs,我有目录的路径 old_file_path="/user/projects/dir1/dir2/dir3/$variable1/$variable2" 其中variable1和variable2是存储在variable中的目录的名称 我知道在名为variable2的目录中,有另一个(而且只有一个)目录在里面。我想将内部目录的名称存储到一个变量中。 请告诉我这样做的命令。 由于所有目录都在HDFS中,所以我使用的命令如下所示,其中oldMemberCount是我用来将目录名存储在variable

我有目录的路径

old_file_path="/user/projects/dir1/dir2/dir3/$variable1/$variable2"
其中variable1和variable2是存储在variable中的目录的名称

我知道在名为variable2的目录中,有另一个(而且只有一个)目录在里面。我想将内部目录的名称存储到一个变量中。 请告诉我这样做的命令。 由于所有目录都在HDFS中,所以我使用的命令如下所示,其中oldMemberCount是我用来将目录名存储在variable2目录中的变量

oldMemberCount=$(hadoop fs -ls $old_file_path)

但是我有错误

你能分享一下你的错误吗?在任何人都能正确地帮助您之前,需要更多关于正在发生的事情的信息。在常规文件系统中,我会这样做:
oldMemberCount=$(find$old\u file\u path-type d-print)
。这仅在只有一个目录时有效。它是递归的,所以要小心。