簡體   English   中英

使用Bash腳本從環境變量中的路徑獲取基名

[英]Get basename from path in env variables using a Bash script

我需要從env變量中獲取基本名稱,例如,我的basePath是basePath =“ x / y / z / t”,我想要t,我正在執行以下操作:

$(basename $basePath)

但這沒有幫助。

同樣,我想從該路徑中獲取最新的更新文件夾/文件,如下所示:

$(basename $(ls -td '$basePath'/*/ | head -n1))

但這也無濟於事。

請嘗試以下操作:

basePath="x/y/z/t"

# Find latest files modified in the last 24 Hours
find ${basePath/*\/} -type f -mtime +1

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM