庆典 - 脚本不会工作内化目录 [英] bash - change directory inside a script wont work

查看:83
本文介绍了庆典 - 脚本不会工作内化目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

结果
尝试寻找问题的解决方案,但具有下列stucked:


Try to find a solution for a problem but stucked with the following :

我有一个文件夹的路径(我有完整路径和局部路径)。结果
林绑cd到该文件夹​​,但它一直说没有这样的文件或目录。
那部分code:

I have a path of a folder (I got full path and partial path).
Im tying to cd to that folder, but it keep saying "No such file or directory". Thats the partial code :

for var in "$@" ; do
    if [[ -d $var ]] ; then
        if [ "$(ls -A $var)" ]; then
            cd $var

请问appericiate任何帮助:)
谢谢

Would appericiate any help :) Thanks

推荐答案

我觉得这行是你的问题:

I think this line is your problem:

    if [ "$(ls -A $var)" ]; then

为什么你需要在所有这个测试?您的previous检查查找已在目录的存在。

Why do you need this test at all? Your previous check looks for the existence of the directory already.

这篇关于庆典 - 脚本不会工作内化目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆