gpt4 book ai didi

bash - 将最新目录获取到 Bash 中的变量

转载 作者:行者123 更新时间:2023-11-29 08:42:31 24 4
gpt4 key购买 nike

我想在一个目录中找到最新的子目录,并将结果保存到 bash 中的变量。

像这样:

ls -t /backups | head -1 > $BACKUPDIR

有人能帮忙吗?

最佳答案

BACKUPDIR=$(ls -td /backups/*/ | head -1)

$(...) 在子 shell 中计算语句并返回输出。

关于bash - 将最新目录获取到 Bash 中的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9275964/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com