list all folder names in directory - unix shell script list all folder names in directory - unix shell script hadoop hadoop

list all folder names in directory - unix shell script


You need to ask hdfs if the folder is a directory, not bash.

if hdfs dfs -test -d "$folder"; then


if ! hdfs dfs -test -d $path_on_hdfs; then

echo "Folder Not Present.Creating it"

hdfs dfs -mkdir -d $path_on_hdfs

else

echo "Already present. Delete and re-create"

hdfs dfs -rmr -skipTrash $path_on_hdfs

fi

The above code will create the folder if it is nor present and will delete the folder if it is present.

Thanks,

Regards,

Dheeraj Rampally.