2013-12-09 5 views

답변

0

을 : GNU 합계와

tr \\n \\0<files.txt|xargs -0 stat -f'%m %N'|sort -rn|head -n1 

사용 -c'%Y %n'을. 수정 날짜별로 정렬 된 파일을 찾을 수

다른 방법 :

find . -type f -exec stat -f'%m %N' {} +|sort -rn|cut -d' ' -f2- 
    for OS X's stat; use -c'%Y %n' with GNU stat 
gfind -type f -printf '%[email protected] %p\n'|sort -rn|cut -d' ' -f2- 
    %[email protected] is absolute modification time and %p is pathname 
zsh -o dotglob -c 'printf %s\\n **/*(.om)' 
    . is a qualifier for regular files 
    om orders files by modification time 
0

이 시도 : OS X의 합계를 들어

find . -type f | xargs stat --format '%Y :%y %n' | sort -nr | cut -d' ' -f5- | head 


find . -type f # find all FILES only in the current directory 
xargs stat --format '%Y :%y %n' # perform a stat on the file 
           # (xargs helps in 'stringing together commands') 
           # %Y time of last modification since Epoch 
           # %y time of last modification human readable 
           # %n file name 
sort -nr      # -n, sort according to numerical value, -r reverse 
cut -d' ' -f5     # cut output by ' ' (space) and print column five 
head       # show the first 10 lines 
+0

%의 y는 잘못된 형식입니다, 내가 Mac에서입니다. – hzxu

+0

아하, 미안, 내 잘못이야. 이 링크 [사이트 링크] (http://stackoverflow.com/questions/10197938/last-modified-date-of-a-directory-in-osx) – user2840647

+0

을보고 정렬이 실제로 작동하지 않습니다. stat의 결과는 "16777220 5339950 drwxr-xr-x 4 ..."로 시작하는 것으로, 첫 번째 숫자는 날짜가 아닙니다. – hzxu