安卓shell 移動某個時間之後的檔案到另外一個資料夾 命令記錄

hrdom發表於2024-07-28

find /storage/emulated/0/DCIM/Camera -maxdepth 1 -mtime -1 -type f -exec ls -l {} \; 供先測試一下

ls -l /storage/emulated/0/DCIM/Camera.new | wc -l 供先測試一下

find /storage/emulated/0/DCIM/Camera -maxdepth 1 -mtime -1 -type f -exec mv -iv "{}" /storage/emulated/0/DCIM/Camera.new \;

find --help


usage: find [-HL] [DIR...] [<options>]

Search directories for matching files.
Default: search "." match all -print all matches.

-H Follow command line symlinks -L Follow all symlinks

Match filters:
-name PATTERN filename with wildcards -iname case insensitive -name
-path PATTERN path name with wildcards -ipath case insensitive -path
-user UNAME belongs to user UNAME -nouser user ID not known
-group GROUP belongs to group GROUP -nogroup group ID not known
-perm [-/]MODE permissions (-=min /=any) -prune ignore contents of dir
-size N[c] 512 byte blocks (c=bytes) -xdev only this filesystem
-links N hardlink count -atime N[u] accessed N units ago
-ctime N[u] created N units ago -mtime N[u] modified N units ago
-newer FILE newer mtime than FILE -mindepth # at least # dirs down
-depth ignore contents of dir -maxdepth # at most # dirs down
-inum N inode number N -empty empty files and dirs
-type [bcdflps] (block, char, dir, file, symlink, pipe, socket)
-context PATTERN security context

Numbers N may be prefixed by a - (less than) or + (greater than). Units for
-Xtime are d (days, default), h (hours), m (minutes), or s (seconds).

Combine matches with:
!, -a, -o, ( ) not, and, or, group expressions

Actions:
-print Print match with newline -print0 Print match with null
-exec Run command with path -execdir Run command in file's dir
-ok Ask before exec -okdir Ask before execdir
-delete Remove matching file/dir

Commands substitute "{}" with matched file. End with ";" to run each file,
or "+" (next argument after "{}") to collect and run with multiple files.

cas:/storage/emulated/0/DCIM/Camera $ find --version
toybox 0.8.0-android

history命令,輸出adb shell的歷史命令

cas:/storage/emulated/0/DCIM/Camera $ history
1 cd /storage/emulated/0/DCIM/
2 ls
3 cd Camera
4 ls -l | wc -l
5 find . -mindepth 1 -maxdepth 1 -mtime -3
6 find --help
7 cd ..
8 find
9
10 cd /storage/emulated/0/DCIM/
11 ls
12 cd Camera
13 ls -l | wc -l
14 find . -mindepth 1 -maxdepth 1 -mtime -1 -exec ls -ld "{}" \;

相關文章