Searching for a files based on current date directory
Hi All,
I've been trying to do some recursive searching but not been very successful. Can someone please help.
Scenario:
I have directory structure
so what I want to do is run a script and as its 2019/11/18/ today it would go and only search on that folder and give me number of files init and tomorrow it would search in 2019/11/19/
Last edited by vbe; 11-18-2019 at 12:54 PM..
Reason: code tags use [] not <>
May be a simple question for experts here....
I need to get the list of files older than 30 days in the current folder. I tried "find", but it searches recursively in all the sub directories.
Can I restrict the recursive search and extract the files only from current directory ? (18 Replies)
i want to make a bash script that searches a specific pattern in files through all subdirectories beneath the current directory..without using the command grep-R
but only the command grep..
e.g
for i in *
do
grep "pattern" $i
.....
...
done
using the character (*) the script... (5 Replies)
Hi
I was wondering why command 2 doesn't work like command 1 below.
1.
find . -exec grep "test" '{}' \; -print
2.
ls -R | grep "test"
I am trying to search "test" from all the files in the current and sub directories. What's wrong with my command 2?
Thanks in advance for your help (4 Replies)
Hi All
I was wondering what is the most efficient way to find files in the current directory(that may contain 100,000's files), that meets a certain specified file type and of a certain age.
I have experimented with the find command in unix but it also searches all sub directories. I have... (2 Replies)
hi all,
here is the description to my problem.
input parameters: $date1 & $date2
based on the range i need to select the archived files from the archived directory and moved them in to working directory.
can u please help me in writing the code to select the multiple files based on the... (3 Replies)
Hi, I have a question, is there any way I can, when i create a directory, put the current date on it so that the directory name will be "name-current date"? just curious (3 Replies)
this is what i have to find the files modified within the past 24 hours
find . -mtime -1 -type f -print0 | xargs -0 tar rvf "$archive.tar"
however i need to save/name this archive as the current date (MM-DD,YYYY.tar.gz)
how do i doo this (1 Reply)
Hi All,
I am currently coding for a requirement(LINUX OS) where I am supposed to move a file (Lets Call it Employee.txt) from Directory A to Directory B based on 2 date fields as below,
Date_Current = 20120620
Date_Previous = 20120610
Source Directory : /iis_data/source
Target... (11 Replies)
Hi All,
Really stuck up with a requirement where I need to move a file (Lets say date_Employee.txt--the date will have different date values like 20120612/20120613 etc) from one directory to another based on creation/modification dates.
While visiting couple of posts, i could see we can... (3 Replies)
Hi
I am unable to find files, those are present anywhere in the same directory tree, based on the creation date. I need to find the files with their path, as I need to create them in another location and move them. I need some help with a script that may do the job.
Please help (2 Replies)
Discussion started by: sam192837465
2 Replies
LEARN ABOUT OSF1
scandir
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)