2014-04-11 27 views

回答

1

聽起來像是你想要的LS選項

-t sort by modification time, newest first

而且只顯示目錄,使用類似這樣的回答表明Listing only directories using ls in bash: An examination

ls -d */

如果你想在一行中列出每個目錄(如果你的文件/ dirnames沒有ne wlines或瘋狂的字符)我想補充-1所以都在一起,這應該在頂部

ls -1td */

而且只有單一的最新目錄列出目錄在當前目錄下,用最新的修改時間:

ls -1td */ | head -n 1

或者,如果你要比較一個特定的時間,你可以使用find,它就像-cmin -cnewer -ctime -mmin -mtime選項,並找到能夠處理瘋狂的名字,像換行,空格等與空值終止名選項裏ke -print0

0

子目錄被修改多少是無關緊要的。你知道子目錄的名字嗎?得到它的內容是這樣的:

files=$(ls subdir-name) 
for file in ${files}; do 
    echo "I see there is a file named ${file}" 
done 
+0

對我而言,這並非無關緊要。 –