如何从一个目录跳转到另一目录,同时在屏幕上显示当前的工作目录,否则显示错误?

时间:2019-09-13 03:47:13

标签: linux shell scripting

它显示以下错误:

  

请检查目标目录

enter image description here

1 个答案:

答案 0 :(得分:0)

尝试一下:

var=( /home/divya/dir1 /home/divya/dir2 )
for dir_list in ${var[@]}
do
  cd "${dir_list}"
  test="$(pwd)"
  if [ "${dir_list}" = "${test}" ] ; then
     echo "Destination directory is ${test}"
  else
     echo "Check the destination directory"
 fi
done