在Windows中改变bash脚本中的目录

问题描述 投票:0回答:3

如何在Windows中的bash脚本中更改我的工作目录。我有~dp0 = C:\ test \ docker \ windows,我想将我的目录更改为C:\ test \ build所以它意味着2级,然后是int o build文件夹

谢谢

windows bash path cd
3个回答
1
投票

在我的Git bash系统中,C:\ root只是/c/,而其他的目录都是它们,所以它就是cd /c/test/build/

你还可以说cd ../../build/

祝好运。


0
投票

使用bash脚本更改目录就像使用普通bash一样。

cd "C:/test/build"
echo "You're now in the folder, do what you will."

将文件另存为.sh,可以这样使用。请注意,使用bash脚本导航文件夹时,请记住您将从中开始的目录始终是主目录。


0
投票

Since C:\ is mounted by default into /mnt/c this will work.

按照以下命令在主路径中创建.bashrc:

    echo "BUILDDIR=/mnt/c/test/build" >> ~/.bashrc;source ~/.bashrc
    cd $BUILDDIR         

    # Do your work below for example ./configure.
    ./configure 
© www.soinside.com 2019 - 2024. All rights reserved.