Bash: Geänderte Dateien finden (mtime)
3. Februar 2016 / Bash / Mac / Ubuntu
×Info: This post is older than 2 years! Displayed information may be outdated!
Datein die sich in den letzten 3 Tagen geändert haben als Liste in der Shell ausgeben (nach Größe sortiert).
# cd to dir
sudo find . -type f -mtime -3 -print0 | xargs -0 du -sk | sort -nr
Oder in Datei speichern:
# cd to dir
sudo find . -type f -mtime -3 -print0 | xargs -0 du -sk | sort -nr > ~/Desktop/list.txt
Update 2018
Sort paths of changed files via path (recursively) with Python2. Create filesort.py-file:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os.path
# provide python-list of filepaths, then
filelist = ['/folder/subfolder/a1.txt', '/folder/2.txt', '/folder/1.txt', '/folder/subfolder/b.txt', '/folder/subfolder/a.txt', '/folder/subfolder/a2.txt']
files = filelist
std = sorted(files, key=lambda file: (os.path.dirname(file), os.path.basename(file)))
print std[0]
for i in range(1,len(std)):
if os.path.dirname(std[i]) != os.path.dirname(std[i-1]):
print ""
print std[i]
Run it
chmod +x filesort.py
./filesort.py # make sure to run it with Python2!
# or write to file
./filesort.py > sortedfile.txt
Result
/folder/1.txt
/folder/2.txt
/folder/subfolder/a.txt
/folder/subfolder/a1.txt
/folder/subfolder/a2.txt
/folder/subfolder/b.txt