[英]Cd into first available directory in git bash?
I know in Linux you can use cd */
to get into the first available directory, however I need a way to get into the first directory using Git bash.我知道在 Linux 中,您可以使用
cd */
进入第一个可用目录,但是我需要一种使用 Git bash 进入第一个目录的方法。 I'm writing bash commands for Github Actions that will be run across Linux and Windows machines, so I need a cross-compatible solution.我正在为 Github 编写 bash 命令 将在 ZEDC9F0A5A5D57797BF68E373647797BF68E37364743831Z 和 ZAEA23489A8CE3AA9B630Z6EBAB 机器上运行的操作,所以需要a8CE3AA9B630Z6EBAB。
Running cd */
on Git bash gives me the error bash: cd: too many arguments
.在 Git bash 上运行
cd */
给了我错误bash: cd: too many arguments
cd */
does not "get into the first available directory." cd */
不会“进入第一个可用目录”。 */
expands to the list of all directories in your current directory, which cd
won't accept if there isn't exactly one directory. */
扩展为当前目录中所有目录的列表,如果不完全是一个目录,则cd
不会接受。
You could use an array to capture the list and then cd into the first item in the list:您可以使用数组来捕获列表,然后 cd 进入列表中的第一项:
dirs=(*/)
cd "${dirs[0]}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.