grep dates in a text file to less than 30 days old and move to a new file [duplicate]
This question already has an answer here:
How to grep a date lesser than a particular date in a file [closed]
2 answers
A script that should look out for texts with a date inside the file thats 30 days older than the current date then move to another file like the
$ awk '$NF <= "2018-05-01"' ip.txt
but need a command to get text with dates 30 days older than the system current date automatically without having to manually change the script everyday
grep date
marked as duplicate by G-Man, Ipor Sircer, muru, Rui F Ribeiro, Jeff Schaller Dec 18 at 10:12
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
How to grep a date lesser than a particular date in a file [closed]
2 answers
A script that should look out for texts with a date inside the file thats 30 days older than the current date then move to another file like the
$ awk '$NF <= "2018-05-01"' ip.txt
but need a command to get text with dates 30 days older than the system current date automatically without having to manually change the script everyday
grep date
marked as duplicate by G-Man, Ipor Sircer, muru, Rui F Ribeiro, Jeff Schaller Dec 18 at 10:12
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
A script that should look out for texts with a date inside the file thats 30 days older than the current date then move to another file like the $ awk '$NF <= "2018-05-01"' ip.txt but need a command to get text with dates 30 days older than the system current date automatically without having to manually change the script everyday
– Kasiiku Mark
Dec 19 at 6:10
add a comment |
This question already has an answer here:
How to grep a date lesser than a particular date in a file [closed]
2 answers
A script that should look out for texts with a date inside the file thats 30 days older than the current date then move to another file like the
$ awk '$NF <= "2018-05-01"' ip.txt
but need a command to get text with dates 30 days older than the system current date automatically without having to manually change the script everyday
grep date
This question already has an answer here:
How to grep a date lesser than a particular date in a file [closed]
2 answers
A script that should look out for texts with a date inside the file thats 30 days older than the current date then move to another file like the
$ awk '$NF <= "2018-05-01"' ip.txt
but need a command to get text with dates 30 days older than the system current date automatically without having to manually change the script everyday
This question already has an answer here:
How to grep a date lesser than a particular date in a file [closed]
2 answers
grep date
grep date
edited Dec 19 at 5:58
asked Dec 18 at 6:53
Kasiiku Mark
61
61
marked as duplicate by G-Man, Ipor Sircer, muru, Rui F Ribeiro, Jeff Schaller Dec 18 at 10:12
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by G-Man, Ipor Sircer, muru, Rui F Ribeiro, Jeff Schaller Dec 18 at 10:12
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
A script that should look out for texts with a date inside the file thats 30 days older than the current date then move to another file like the $ awk '$NF <= "2018-05-01"' ip.txt but need a command to get text with dates 30 days older than the system current date automatically without having to manually change the script everyday
– Kasiiku Mark
Dec 19 at 6:10
add a comment |
A script that should look out for texts with a date inside the file thats 30 days older than the current date then move to another file like the $ awk '$NF <= "2018-05-01"' ip.txt but need a command to get text with dates 30 days older than the system current date automatically without having to manually change the script everyday
– Kasiiku Mark
Dec 19 at 6:10
A script that should look out for texts with a date inside the file thats 30 days older than the current date then move to another file like the $ awk '$NF <= "2018-05-01"' ip.txt but need a command to get text with dates 30 days older than the system current date automatically without having to manually change the script everyday
– Kasiiku Mark
Dec 19 at 6:10
A script that should look out for texts with a date inside the file thats 30 days older than the current date then move to another file like the $ awk '$NF <= "2018-05-01"' ip.txt but need a command to get text with dates 30 days older than the system current date automatically without having to manually change the script everyday
– Kasiiku Mark
Dec 19 at 6:10
add a comment |
1 Answer
1
active
oldest
votes
cmd:
for i in {1..30}; do date +%Y-%m-%d -d "$i day ago"; done >outputfile
output:
cat outputfile
2018-12-17
2018-12-16
2018-12-15
2018-12-14
2018-12-13
2018-12-12
2018-12-11
2018-12-10
2018-12-09
2018-12-08
2018-12-07
2018-12-06
2018-12-05
2018-12-04
2018-12-03
2018-12-02
2018-12-01
2018-11-30
2018-11-29
2018-11-28
2018-11-27
2018-11-26
2018-11-25
2018-11-24
2018-11-23
2018-11-22
2018-11-21
2018-11-20
2018-11-19
2018-11-18
$ cat ip.txt Blah blah blah 2018-12-13 Blah blah blah 2018-02-13 Blah blah blah 2018-05-01 $ awk '$NF < "2018-05-01"' ip.txt Blah blah blah 2018-02-13 if possible similar to that without having to manually input the current date as shown in the 2018-05-01 but automatically system date
– Kasiiku Mark
Dec 19 at 6:43
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
cmd:
for i in {1..30}; do date +%Y-%m-%d -d "$i day ago"; done >outputfile
output:
cat outputfile
2018-12-17
2018-12-16
2018-12-15
2018-12-14
2018-12-13
2018-12-12
2018-12-11
2018-12-10
2018-12-09
2018-12-08
2018-12-07
2018-12-06
2018-12-05
2018-12-04
2018-12-03
2018-12-02
2018-12-01
2018-11-30
2018-11-29
2018-11-28
2018-11-27
2018-11-26
2018-11-25
2018-11-24
2018-11-23
2018-11-22
2018-11-21
2018-11-20
2018-11-19
2018-11-18
$ cat ip.txt Blah blah blah 2018-12-13 Blah blah blah 2018-02-13 Blah blah blah 2018-05-01 $ awk '$NF < "2018-05-01"' ip.txt Blah blah blah 2018-02-13 if possible similar to that without having to manually input the current date as shown in the 2018-05-01 but automatically system date
– Kasiiku Mark
Dec 19 at 6:43
add a comment |
cmd:
for i in {1..30}; do date +%Y-%m-%d -d "$i day ago"; done >outputfile
output:
cat outputfile
2018-12-17
2018-12-16
2018-12-15
2018-12-14
2018-12-13
2018-12-12
2018-12-11
2018-12-10
2018-12-09
2018-12-08
2018-12-07
2018-12-06
2018-12-05
2018-12-04
2018-12-03
2018-12-02
2018-12-01
2018-11-30
2018-11-29
2018-11-28
2018-11-27
2018-11-26
2018-11-25
2018-11-24
2018-11-23
2018-11-22
2018-11-21
2018-11-20
2018-11-19
2018-11-18
$ cat ip.txt Blah blah blah 2018-12-13 Blah blah blah 2018-02-13 Blah blah blah 2018-05-01 $ awk '$NF < "2018-05-01"' ip.txt Blah blah blah 2018-02-13 if possible similar to that without having to manually input the current date as shown in the 2018-05-01 but automatically system date
– Kasiiku Mark
Dec 19 at 6:43
add a comment |
cmd:
for i in {1..30}; do date +%Y-%m-%d -d "$i day ago"; done >outputfile
output:
cat outputfile
2018-12-17
2018-12-16
2018-12-15
2018-12-14
2018-12-13
2018-12-12
2018-12-11
2018-12-10
2018-12-09
2018-12-08
2018-12-07
2018-12-06
2018-12-05
2018-12-04
2018-12-03
2018-12-02
2018-12-01
2018-11-30
2018-11-29
2018-11-28
2018-11-27
2018-11-26
2018-11-25
2018-11-24
2018-11-23
2018-11-22
2018-11-21
2018-11-20
2018-11-19
2018-11-18
cmd:
for i in {1..30}; do date +%Y-%m-%d -d "$i day ago"; done >outputfile
output:
cat outputfile
2018-12-17
2018-12-16
2018-12-15
2018-12-14
2018-12-13
2018-12-12
2018-12-11
2018-12-10
2018-12-09
2018-12-08
2018-12-07
2018-12-06
2018-12-05
2018-12-04
2018-12-03
2018-12-02
2018-12-01
2018-11-30
2018-11-29
2018-11-28
2018-11-27
2018-11-26
2018-11-25
2018-11-24
2018-11-23
2018-11-22
2018-11-21
2018-11-20
2018-11-19
2018-11-18
answered Dec 18 at 8:53
Praveen Kumar BS
1,206138
1,206138
$ cat ip.txt Blah blah blah 2018-12-13 Blah blah blah 2018-02-13 Blah blah blah 2018-05-01 $ awk '$NF < "2018-05-01"' ip.txt Blah blah blah 2018-02-13 if possible similar to that without having to manually input the current date as shown in the 2018-05-01 but automatically system date
– Kasiiku Mark
Dec 19 at 6:43
add a comment |
$ cat ip.txt Blah blah blah 2018-12-13 Blah blah blah 2018-02-13 Blah blah blah 2018-05-01 $ awk '$NF < "2018-05-01"' ip.txt Blah blah blah 2018-02-13 if possible similar to that without having to manually input the current date as shown in the 2018-05-01 but automatically system date
– Kasiiku Mark
Dec 19 at 6:43
$ cat ip.txt Blah blah blah 2018-12-13 Blah blah blah 2018-02-13 Blah blah blah 2018-05-01 $ awk '$NF < "2018-05-01"' ip.txt Blah blah blah 2018-02-13 if possible similar to that without having to manually input the current date as shown in the 2018-05-01 but automatically system date
– Kasiiku Mark
Dec 19 at 6:43
$ cat ip.txt Blah blah blah 2018-12-13 Blah blah blah 2018-02-13 Blah blah blah 2018-05-01 $ awk '$NF < "2018-05-01"' ip.txt Blah blah blah 2018-02-13 if possible similar to that without having to manually input the current date as shown in the 2018-05-01 but automatically system date
– Kasiiku Mark
Dec 19 at 6:43
add a comment |
A script that should look out for texts with a date inside the file thats 30 days older than the current date then move to another file like the $ awk '$NF <= "2018-05-01"' ip.txt but need a command to get text with dates 30 days older than the system current date automatically without having to manually change the script everyday
– Kasiiku Mark
Dec 19 at 6:10