how to delete privious year june files from the list [duplicate]

Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
This question already has an answer here:
How to get the difference between modified date and current date in shell script? [closed]
2 answers
How to delete previous year June files from the list
#!/bin/bash
echo "hi"
path="/home/alert/VideoApplicationAPI.v1/logs"
dayDiff=365
DATE=`date +%Y-%m-%d`
for filename in $path/*.*; do
modDate=$(stat -c %y "$filename")
modDate=$modDate%% *
echo $filename:$modDate
echo "( `date -d $DATE +%s` - `date -d $modDate +%s`) / (24*3600)" | bc -l
done
echo $DATE
shell-script
marked as duplicate by Romeo Ninov, Community♦ Mar 15 at 8:28
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 get the difference between modified date and current date in shell script? [closed]
2 answers
How to delete previous year June files from the list
#!/bin/bash
echo "hi"
path="/home/alert/VideoApplicationAPI.v1/logs"
dayDiff=365
DATE=`date +%Y-%m-%d`
for filename in $path/*.*; do
modDate=$(stat -c %y "$filename")
modDate=$modDate%% *
echo $filename:$modDate
echo "( `date -d $DATE +%s` - `date -d $modDate +%s`) / (24*3600)" | bc -l
done
echo $DATE
shell-script
marked as duplicate by Romeo Ninov, Community♦ Mar 15 at 8:28
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 get the difference between modified date and current date in shell script? [closed]
2 answers
How to delete previous year June files from the list
#!/bin/bash
echo "hi"
path="/home/alert/VideoApplicationAPI.v1/logs"
dayDiff=365
DATE=`date +%Y-%m-%d`
for filename in $path/*.*; do
modDate=$(stat -c %y "$filename")
modDate=$modDate%% *
echo $filename:$modDate
echo "( `date -d $DATE +%s` - `date -d $modDate +%s`) / (24*3600)" | bc -l
done
echo $DATE
shell-script
This question already has an answer here:
How to get the difference between modified date and current date in shell script? [closed]
2 answers
How to delete previous year June files from the list
#!/bin/bash
echo "hi"
path="/home/alert/VideoApplicationAPI.v1/logs"
dayDiff=365
DATE=`date +%Y-%m-%d`
for filename in $path/*.*; do
modDate=$(stat -c %y "$filename")
modDate=$modDate%% *
echo $filename:$modDate
echo "( `date -d $DATE +%s` - `date -d $modDate +%s`) / (24*3600)" | bc -l
done
echo $DATE
This question already has an answer here:
How to get the difference between modified date and current date in shell script? [closed]
2 answers
shell-script
shell-script
edited Mar 15 at 7:51
Romeo Ninov
7,02232129
7,02232129
asked Mar 15 at 7:33
Himanshu KumarHimanshu Kumar
61
61
marked as duplicate by Romeo Ninov, Community♦ Mar 15 at 8:28
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 Romeo Ninov, Community♦ Mar 15 at 8:28
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 |
add a comment |
1 Answer
1
active
oldest
votes
touch -d '2018-06-01 00:00:00' START
touch -d '2018-07-01 00:00:00' END
find <path of files to be deleted> -type f -newer START -not -newer END -exec rm ;
The start and end will give you the date range. That is 2018 June. You can first run only find command, to see what all files you get. If the files are correct, then execute the above command. Make sure you have a back up of all the files, in case if something goes wrong while execution.
1
thnx i got my result
– Himanshu Kumar
Mar 15 at 9:45
If this has helped you, please accept the answer by ticking it.
– Programmer
Mar 15 at 10:22
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
touch -d '2018-06-01 00:00:00' START
touch -d '2018-07-01 00:00:00' END
find <path of files to be deleted> -type f -newer START -not -newer END -exec rm ;
The start and end will give you the date range. That is 2018 June. You can first run only find command, to see what all files you get. If the files are correct, then execute the above command. Make sure you have a back up of all the files, in case if something goes wrong while execution.
1
thnx i got my result
– Himanshu Kumar
Mar 15 at 9:45
If this has helped you, please accept the answer by ticking it.
– Programmer
Mar 15 at 10:22
add a comment |
touch -d '2018-06-01 00:00:00' START
touch -d '2018-07-01 00:00:00' END
find <path of files to be deleted> -type f -newer START -not -newer END -exec rm ;
The start and end will give you the date range. That is 2018 June. You can first run only find command, to see what all files you get. If the files are correct, then execute the above command. Make sure you have a back up of all the files, in case if something goes wrong while execution.
1
thnx i got my result
– Himanshu Kumar
Mar 15 at 9:45
If this has helped you, please accept the answer by ticking it.
– Programmer
Mar 15 at 10:22
add a comment |
touch -d '2018-06-01 00:00:00' START
touch -d '2018-07-01 00:00:00' END
find <path of files to be deleted> -type f -newer START -not -newer END -exec rm ;
The start and end will give you the date range. That is 2018 June. You can first run only find command, to see what all files you get. If the files are correct, then execute the above command. Make sure you have a back up of all the files, in case if something goes wrong while execution.
touch -d '2018-06-01 00:00:00' START
touch -d '2018-07-01 00:00:00' END
find <path of files to be deleted> -type f -newer START -not -newer END -exec rm ;
The start and end will give you the date range. That is 2018 June. You can first run only find command, to see what all files you get. If the files are correct, then execute the above command. Make sure you have a back up of all the files, in case if something goes wrong while execution.
answered Mar 15 at 7:55
ProgrammerProgrammer
459
459
1
thnx i got my result
– Himanshu Kumar
Mar 15 at 9:45
If this has helped you, please accept the answer by ticking it.
– Programmer
Mar 15 at 10:22
add a comment |
1
thnx i got my result
– Himanshu Kumar
Mar 15 at 9:45
If this has helped you, please accept the answer by ticking it.
– Programmer
Mar 15 at 10:22
1
1
thnx i got my result
– Himanshu Kumar
Mar 15 at 9:45
thnx i got my result
– Himanshu Kumar
Mar 15 at 9:45
If this has helped you, please accept the answer by ticking it.
– Programmer
Mar 15 at 10:22
If this has helped you, please accept the answer by ticking it.
– Programmer
Mar 15 at 10:22
add a comment |