Aswex
October 20, 2010, 8:10am
1
Hello,
Due to an error while processing data I have to delete all files created the 4 october on a RED HAT 3 Server.
I am wondering if one of you is aware of a command that could only delete all files that were created the
Oct 4
This will be very, very, very helpful
Thanks for your help.
cabrao
October 20, 2010, 8:15am
2
Maybe something like this:
ls -lrt | awk '/Oct 4/ {print $NF}' | xargs echo rm -rf
ctsgnb
October 20, 2010, 8:23am
3
The cabrao statement suppose that none of your file created on the 4 Oct has been modified a further day :
ls -lrt would display last modification date, not the creation date ...
Aswex
October 20, 2010, 8:25am
4
Dear Cabrao,
Sorry this deosn't work for me. The result does not match with the number of files that I should delete.
Thanks anyway for your help.
cabrao
October 20, 2010, 8:43am
5
I didn't read the part saying "..files created..." sorry.
I don't know how to do it and according to the UNIX FAQ, it is not possible to see the file creation time.
Files have a last-modified time (shown by "ls -l"), a last-accessed time (shown by "ls -lu") and an inode change time (shown by "ls -lc").
http://www.faqs.org/faqs/unix-faq/faq/part3/section-1.html
1 Like
Aswex
October 20, 2010, 9:00am
6
Thanks for your help ... I will try to do it manually ...
But thanks for your help
IND123
October 20, 2010, 9:50am
7
ls -lrt | awk '/Oct 4/ {print $NF}' |\
while read filename; do
echo "File getting deleted is --> ${filename}"
rm -f "${filename}"
done;
You can put the above code in the script and run it to delete the files.