Why the for loop for a single $1 parameter without wild cards? Why the removal of today's and older files when you want 6+ days? Why the /* appended to the ${_DIR}?
Please post an execution log after setting the -x option.
"still doesn't work" is NOT something that people trying to help can build on, and thus doesn't answer my first question. And, don't switch topic / code / targets between posts - first you wanted to remove files, now it's directories.
Some hints:
- rmdir fails on non-empty directories.
- are folders older than 6 days around, at all?
- find can take multiple starting directories - no need for a for loop.
Here is what I arrived at with your help of the definitions in your last response.
The reason I"m using a for loop is so I can check what path is being passed in as certain files/directories have different retention requirements.
So, at the end of my script(s), I'd put this:
For this purpose ( & script) I only need to pass in the log and error directories since nothing major happens. However, for data integration scripts, data exports, the _DLIST variable would be inclusive of many more.
Then my function looks like such:
As an example, for this purpose, the following to paths are passed in:
If the baseline folder is detected as YEAR_MONTHDAY format, I strip that off first before purging or else it wouldn't hit the other YEAR_MONTHDAY folders in the /PBCS_Reset_Service_*/ directory.
Let me know if I'm way off base here - thanks!
Last edited by SIMMS7400; 06-15-2018 at 07:49 PM..
Hi Team,
I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder.
Eg:
parent folder --> /Interface/data/test/IN
Sub folder -->/Interface/data/test/IN/Invoice20180607233338
Subfolder will be always with timestamp... (6 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 Experts,
i need a little help.
i have different folder that contain files that need to be deleted. but those folder contains huge amoung of same with 3 different extention.
what i used to do is to delete them using the rm commande
rm *.ext *.ext1 *.ext3
what i want to do is to have... (1 Reply)
Hi All,
Need a for loop which should run for number of files in a folder and should pass the file name as parameter to another shell script for each loop.
Please help me.
Thanks. (2 Replies)
Hi,
I need to use rsync to delete multiple files(only specified files not all) using --delete option, these files are located in different target folders.
Instead of running rsync command multiple times for each file, can we achieve this with one time execution?
your help is much... (0 Replies)
Hi all,
I need to write a script to naviagate into the list of specified folder and delete the files in it.
I have mentioned the list of folders in a external file so it can be reusable.
The issue is am facing now is that, i am not understating on how to navigate into the folder locations... (6 Replies)
Hi I have files that end with .txt.txt that i want to delete. But I also have files that end with .txt that I want to leave intact. How do I specifically delete files that end with .txt.txt in a folder.
thanks (5 Replies)
Hi ,
I need a script which basically deltes all files in folder a which are alreasy present in folder b
say folder a has files abc.txt
pqr .txt
and b has abc.txt
pqr.txt
rmr.txt
then file abc.txt and pqr.txt from a should be deleted (6 Replies)
Hi,
I want to write a script that deletes all folders and keep the last 10 recent folders.
I know the following:
ls -ltr will sort the folders from old to recent.
ls -ltr | awk '{print $9}' will list the folder names (with a blank line at the beginning)
I want to get the 10th folder from... (3 Replies)