【问题标题】:How to jump from one directory to another directory and also display the present working directory on screen otherwise show the error?如何从一个目录跳转到另一个目录并在屏幕上显示当前工作目录,否则显示错误?
【发布时间】:2019-09-13 03:47:13
【问题描述】:

显示如下错误:

请检查目标目录

【问题讨论】:

  • 非必要请勿截图。在您的情况下,您同样可以直接发布代码,当然要使用正确的格式。您的解决方案不起作用,因为您在子进程中更改了工作目录,而不是在您测试新工作目录的进程中。

标签: linux shell scripting


【解决方案1】:

试试这个:

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

【讨论】:

    猜你喜欢
    • 2010-12-22
    • 2021-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-26
    • 2012-10-25
    • 1970-01-01
    相关资源
    最近更新 更多