Sponsored Content
Top Forums Shell Programming and Scripting Find the number of files older than 1 day from a dir Post 302480914 by NARESH1302 on Thursday 16th of December 2010 06:15:16 AM
Old 12-16-2010
I just ran the command to test it (removing -mtime +1 option), failed.
Code:
find /home/npradhan/naresh -type f -name "*.csv" -exec "ls -lrt" {} \;
find: ls -lrt: No such file or directory
find: ls -lrt: No such file or directory


Last edited by Scott; 12-16-2010 at 08:17 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find files older than 20 days & not use find

I need to find files that have the ending of .out and that are older than 20 days. However, I cannot use find as I do not want to search in the directories that are underneath the directory that I am searching in. How can this be done?? Find returns files that I do not want. (2 Replies)
Discussion started by: halo98
2 Replies

2. Shell Programming and Scripting

Deleting / finding files older than X days missess a day

Hi When trying to find and delete files which are, say, 1 day, the find command misses a day. Please refer the following example. xxxd$ find . -type f -ctime +1 -exec ls -ltr {} \; total 64 -rw-rw-r-- 1 oracle xxxd 81 Apr 30 11:25 ./ful_cfg_tmp_20080429_7.dat -rw-rw-r-- 1... (4 Replies)
Discussion started by: guruparan18
4 Replies

3. Shell Programming and Scripting

need to move files of particular day from one dir to another dir

Hi, I have hundered's of files of the name CMP_PORT_IN_P200903271623042437_20090328122430_err.xml in error directory of todays date ie 20090328 and in the file name 5th field specifies date only now i want to move all files of 20090328 to another directory i.e reprocess directory. So... (3 Replies)
Discussion started by: ss_ss
3 Replies

4. Shell Programming and Scripting

A script to find dir, delete files in, and then del dir?

Hello!! I have directories from 2008, with files in them. I want to create a script that will find the directoried from 2008 (example directory: drwxr-xr-x 2 isplan users 1024 Nov 21 2008 FILES_112108), delete the files within those directories and then delete the directories... (3 Replies)
Discussion started by: bigben1220
3 Replies

5. Shell Programming and Scripting

KSH - Find paths of multiple files in CC (dir and sub-dir))

Dear Members, I have a list of xml files like abc.xml.table prq.xml.table ... .. . in a txt file. Now I have to search the file(s) in all directories and sub-directories and print the full path of file in a output txt file. Please help me with the script or command to do so. ... (11 Replies)
Discussion started by: Yoodit
11 Replies

6. UNIX for Dummies Questions & Answers

List files older that 7 days in a dir, excluding all subdirs

Hi, I would like to list all files, older than 7 days, in a directory, but exclude all subdirectories in the find command. If I use find . -type f -mtime +7 all files in the subdirs are also included. How can I exclude them? Regards, JW (6 Replies)
Discussion started by: jwbijl
6 Replies

7. Shell Programming and Scripting

How archive the older than 30 day files to another unix server

I need to archive the older than 30 day file to another uinx server.I have wrote the below uinx script. for LOOK_DIR in /TempFiles do for FILE in `find ${LOOK_DIR} -mtime -30 -exec ls {} \;` do echo ${FILE} >> file_list ## This file will have the list of files copied and... (12 Replies)
Discussion started by: murari83.ds
12 Replies

8. Shell Programming and Scripting

Sftp - 1 day older files count

Need to write a shell script on AIX box which will connect to different servers using SFTP and get the file count of only 1 day older files. (purging list) How to achieve this? On local server we can use: find <path> -type f -mtime +1 But how to do it in case of SFTP? Please advise. Thanks... (9 Replies)
Discussion started by: vegasluxor
9 Replies

9. Shell Programming and Scripting

Find processes older than 1 day

// AIX 6.1 I need to extract PIDs of ps -ef |grep /usr/lib/lpd/pio | awk '{print $2}' ps -ef |grep qdaemon |grep /usr/bin/ksh | awk '{print $2}' that are older than 1 day. I know find . -type f -mtime +1, but it doesn't work for PIDs. Please let me know how to get the PIDs older than... (1 Reply)
Discussion started by: Daniel Gate
1 Replies

10. Shell Programming and Scripting

Grep files older than 1 day

I thought that this would work for grep'ing files older than 1 day. ps -o etime,pid,user,args -e|awk '/^+-/'|sort -t- -n -k 1,1 |grep qdaemon |grep /usr/bin/ksh But, it is not grep'ing any of files (i.e. below) older than 1 day. d_prod 33757970 61999560 0 Oct 27 - 0:00... (8 Replies)
Discussion started by: Daniel Gate
8 Replies
find(1) 						      General Commands Manual							   find(1)

Name
       find - find files

Syntax
       find pathname-list  expression

Description
       The  command  recursively  descends the directory hierarchy for each pathname in the pathname-list (that is, one or more pathnames) seeking
       files that match a boolean expression written in the primaries given below.  In the descriptions, the argument n is used as a decimal inte-
       ger where +n means more than n, -n means less than n , and n means exactly n.

Options
       -atime n       Tests true if the file has been accessed in n days.

       -cpio output   Writes current file on output in the format (5120-byte records) specified in the reference page.	The output can be either a
		      file or tape device.  If output is a tape device the B key must be used to read data from the tape.

       -ctime n       Tests true if the file has been changed in n days.

       -depth	      Always true; causes descent of the directory hierarchy to be done so that all entries in a directory are acted on before the
		      directory  itself (that is, postorder instead of preorder).  This can be useful when is used with to transfer files that are
		      contained in directories without write permission.

       -exec command  Tests true if specified command returns a 0 on exit.  The end of the command must be punctuated by an escaped semicolon.	 A
		      command argument `{}' is replaced by the current pathname.

       -group gname   Tests true if group ID matches specified group name.

       -inum n	      Tests true if the file has inode number n.

       -links n       Tests true if the file has n links.

       -mount	      Tests true if the current file is on the same file system as the current starting pathname.

       -mtime n       Tests true if the file has been modified in n days.

       -name filename Tests  true  if  the  filename  argument matches the current file name.  Normal Shell argument syntax may be used if escaped
		      (watch out for `[', `?' and `*').

       -newer file    Tests true if the current file has been modified more recently than the argument file.

       -ok command    Executes specified command on standard output, then standard input is read and command executed only upon response y.

       -perm onum     Tests true if file has specified octal number.  For further information, see If onum is prefixed by a minus sign, more  flag
		      bits (017777) become significant and the flags are compared: (flags&onum)==onum.	For further information, see

       -print	      Prints current pathname.

       -size n	      Tests true if the file is n blocks long (512 bytes per block).

       -type c	      Tests  true  if  file is c type ( c = b, block special file: c, character special file: d, directory: f, plain file: l, sym-
		      bolic link: p, type port: s, type socket).

       -user uname    Tests true if file owner is login name or numeric user ID.

       The primaries may be combined using the following operators (in order of decreasing precedence):

       1)  A parenthesized group of primaries and operators (parentheses are special to the Shell and must be escaped).

       2)  The negation of a primary (`!' is the unary not operator).

       3)  Concatenation of primaries (the and operation is implied by the juxtaposition of two primaries).

       4)  Alternation of primaries (`-o' is the or operator).

Examples
       To remove all files named `a.out' or `*.o' that have not been accessed for a week:
       find / ( -name a.out -o -name '*.o' ) 
       -atime +7 -exec rm {} ;

       To find all files on the root file system type:
       find / -mount -print

       To write all the files on the root file system to tape:
       find / -mount -print -cpio /dev/rmt?h
       cpio -iBvt < /dev/rmt?h

       To find all the mount points on the root file system type:
       find / ! -mount -print

Files
See Also
       cpio(1), sh(1), test(1), cpio(5), fs(5)

																	   find(1)
All times are GMT -4. The time now is 09:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy