read -r reads raw. If backslash escape sequences occur in your input, they will not be interpreted. E.g., if the input has \n, it will be treated as \n and not as a new-line. You'll get the input as is with no such interpretation by read.
This User Gave Thanks to elixir_sinari For This Post:
For the same code, I have an additional requirement. How can we have 2 parameters passed from the input file dirlist.txt? The two parameters would be 1. Teh directory path 2. The retention days
In short , now I wanna write a script taht would delete files older than the retention period. This period should be different for different directory paths. Till now I have written this piece of code.
The dirlist.txt can have sample input as
wherein 7,4 and 9 are retention days for which the files have to be kept and the files older than these should be deleted.
Hi,
One more requirement for the same code. Along with the two parameters in the input file, I want to add one more parameter i.e. file extension. This parameter will be different for different paths.
Th input file will now look like this:
For this, my command goes like this:
The problem is , it is not listing any file in the output. Can anyone please let me know where am I going wrong?
Hi,
I have multiple files in my log folder. e.g:
a_m1.log
b_1.log
c_1.log
d_1.log
b_2.log
c_2.log
d_2.log
e_m1.log
a_m2.log
e_m2.log
I need to keep latest 10 instances of each file.
I can write multiple find commands but looking if it is possible in one line.
m file are monthly... (4 Replies)
hi i need a script to delete the files older than 2 days...
if my input is say in a folder versions
A_14122012.txt
A_15122012.txt
A_16122012.txt
A_17122012.txt
i want my output to be
A_16122012.txt
A_17122012.txt
thanks in advance
hemanth saikumar. (2 Replies)
Hi All,
I am using below code to delete files older than 2 days. In case if there are no files, I should log an error saying no files to delete.
Please let me know, How I can achive this.
find /path/*.xml -mtime +2
Thanks and Regards
Nagaraja. (3 Replies)
Hi all,
I want to delete log files with extension .log which are older than 30
days. How to delete those files?
Operating system -- Sun solaris 10
Your input is highly appreciated.
Thanks in advance.
Regards,
Williams (2 Replies)
i have to delete files which are older than 15 days or more except the ones in the directory Current and also *.sh files
i have found the command for files 15 days or more older
find . -type f -mtime +15 -exec ls -ltr {} \;
but how to implement the logic to avoid directory Current and also... (3 Replies)
I will like to write a script that delete all files that are older than 7 days in a directory and it's subdirectories. Can any one help me out witht the magic command or script?
Thanks in advance,
Odogboly98:confused: (3 Replies)