回答編集履歴
2
追記
test
CHANGED
@@ -31,3 +31,7 @@
|
|
31
31
|
20180728123456.txt
|
32
32
|
|
33
33
|
```
|
34
|
+
|
35
|
+
上記のように'N months ago'とすれば、月の大小を考慮して計算してくれます。
|
36
|
+
|
37
|
+
60日前なら'60 days ago'とします。
|
1
訂正
test
CHANGED
@@ -14,13 +14,13 @@
|
|
14
14
|
|
15
15
|
20180728123456.txt
|
16
16
|
|
17
|
-
$ d=`date -d '2 months ago' '+%Y%m%d%H%M%S'`.txt;ls *.txt|grep -E '[0-9]{14}.txt'|while read f;do [[ $f < $d ]]&&echo $f;done
|
17
|
+
$ d=`date -d '2 months ago' '+%Y%m%d%H%M%S'`.txt;ls *.txt|grep -E '^[0-9]{14}.txt$'|while read f;do [[ $f < $d ]]&&echo $f;done
|
18
18
|
|
19
19
|
20180724123456.txt
|
20
20
|
|
21
21
|
20180725123456.txt
|
22
22
|
|
23
|
-
$ d=`date -d '2 months ago' '+%Y%m%d%H%M%S'`.txt;ls *.txt|grep -E '[0-9]{14}.txt'|while read f;do [[ $f < $d ]]&&echo $f;done|xargs rm
|
23
|
+
$ d=`date -d '2 months ago' '+%Y%m%d%H%M%S'`.txt;ls *.txt|grep -E '^[0-9]{14}.txt$'|while read f;do [[ $f < $d ]]&&echo $f;done|xargs rm
|
24
24
|
|
25
25
|
$ ls -1 *.txt
|
26
26
|
|