Script needed to delete to the list of files in a directory based on last created & delete them
Hi
My directory structure is as below.
I have the list of files to be deleted in the below path as below.
and inside there directories it has files as below - based on directory name.
I want to have a script which can read the content of these files and delete the files inside them and log what was deleted.
Last edited by Scrutinizer; 03-02-2015 at 08:01 AM..
Reason: CODE tags
I have a file <filestodelete> containing names of files to to be deleted from a directory <filesstore>.
I want a script file which accptes the <filestodelete> and also the location of the directory(<filestore>) and deletes all files matching.
Thanks in Advance.. (3 Replies)
There is a system logging a huge amount of data and we need to delete some of the older logs .I mean the files that are created before one week from today. Here is a listing of files that are sitting there:
/usr/WebSphere/AppServer/logs
# ls -l
-rw-r--r-- 1 root system 3740694 May... (5 Replies)
I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell... (2 Replies)
Hi all,
I need a script to delete a large set of files from a directory under / based on an input file and want to redirect errors into separate file.
I have already prepared a list of files in the input file.
Kndly help me.
Thanks,
Prash (36 Replies)
ENVIROMENT
Linux: Fedora Core release 1 (Yarrow)
iPlanet: iPlanet-WebServer-Enterprise/6.0SP1
Log Path: /usr/iplanet/servers/https-company/logs
I have iPlanet log rotation enabled rotating files on a daily basis.
The rotated logs are NOT compressed & are taking up too much space.
I... (7 Replies)
I want to use my script to get any file then delete it once it transfers to my side , I manage to create below script to generate "list" file which contains all file names in "10.10.1.1" then I made "a.out" file which contains the commands that I want to run it on "10.10.1.1" to get & delete the... (2 Replies)
Hello, i'm trying to solve this script.
List, one at a time, all files larger than 100K in the /home/username directory tree. Give the
user the option to delete or compress the file, then proceed to show the next one. Write to a
logfile the names of all deleted files and the deletion times.
I... (7 Replies)
Hi All,
Do you have any sample script,
- auto get file from SFTP remote server and delete file in remove server after downloaded.
- only download specify filename
- auto upload file from local to SFTP remote server and delete local folder file after uploaded
- only upload specify filename
... (3 Replies)
I have more than 200K files created in year 2017 under directory having size of 50GB.
I want to all these files in one shot.
Is there any faster option available with find command to delete all these file ? (6 Replies)
Discussion started by: sp23029
6 Replies
LEARN ABOUT OSF1
alphasort
scandir(3) Library Functions Manual scandir(3)NAME
scandir, alphasort - Scans or sorts directory contents
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <sys/types.h> #include <sys/dir.h>
int scandir ( char *dir_name, struct dirent * (*name_list[ ]), int (*select) ( struct dirent *dir ), int (*compare) (
struct dirent **dir1, struct dirent **dir2 ) );
int alphasort ( struct dirent **dir1, struct dirent **dir2 );
PARAMETERS
Points to the directory name. Points to the array of pointers to directory entries. Points to a user-supplied function that is called by
the scandir() function to select which entries to include in the array. Points to a user-supplied function that sorts the completed
array. Points to a dirent structure. Points to a dirent structure.
DESCRIPTION
The scandir() function reads the directory pointed to by the dir_name parameter. It then uses the malloc() function to create an array of
pointers to directory entries. The scandir() function returns the number of entries in the array and, through the name_list parameter, a
pointer to the array.
The select parameter points to a user-supplied function that the scandir() function calls to select which entries to include in the array.
The selection routine is passed a pointer to a directory entry and returns a nonzero value for a directory entry that is included in the
array. If the select parameter is a null value, all directory entries are included.
The compare parameter points to a user-supplied function that is passed to the qsort() function to sort the completed array. If the compare
parameter is a null value, the array is not sorted.
The memory allocated to the array can be deallocated by freeing each pointer in the array, and the array itself, with the free() function.
The alphasort() function alphabetically compares the two dirent structures pointed to by the dir1 and dir2 parameters. This function can be
passed as the compare parameter to either the scandir() function or the qsort() function. A user-supplied subroutine may also be used.
RETURN VALUES
The scandir() function returns -1 if the directory cannot be opened for reading or if the malloc() function cannot allocate enough memory
to hold all the data structures. If successful, the scandir() function returns the number of entries found.
The alphasort() function returns the following values: Less than 0 (zero): The dirent structure pointed to by the dir1 parameter is lexi-
cally less than the dirent structure pointed to by the dir2 parameter. 0 (zero): The dirent structures pointed to by the dir1 parameter
and the dir2 parameter are equal. Greater than 0 (zero): The dirent structure pointed to by the dir1 parameter is lexically greater than
the dirent structure pointed to by the dir2 parameter.
RELATED INFORMATION
Functions: malloc(3), opendir(3), qsort(3) delim off
scandir(3)