08-31-2004
find command not giving file names accord. to timestamps
Currently iam working on solaris environment,
Iam using find command to get list of all files between any two given dates. But the find command is not listing files accord. to timestamp. I tried using -exec option as -exec ls -ltr {} \;
Still the files are not listed according to timestamp..
Can anyone help me on this..
find . -type f -name '*xyz*' -newer start.file ! -newer end.file
-exec ls -ltr {} \;
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I want to have the timestamps of the files containing a specific string in them.
I have tried using different combinations of find command and grep and ls but not giving the desired output.
find $HOME/bin/shells -name "*" -print -exec ls -Flt {} -exec grep -i "abc" '{}' \;
Please help. (8 Replies)
Discussion started by: nguda
8 Replies
2. UNIX for Advanced & Expert Users
Hi all,
I need help to find out if it is possible (if so, how? :D ) to move a hard link to a given file without making the main file i-node modification time change.
That is:
I have a file myFile.txt ,
and I have a link myLink.dat to that file (obtained by: ln myFile.txt myLink.dat).... (1 Reply)
Discussion started by: gian1975
1 Replies
3. UNIX for Advanced & Expert Users
Hi All,
Iam trying to find two kinds of files while ignoring rest of the files in a directory
The files are like below
Files to be found
--------------------
perp45560
oerp4556
Files to be ignored
----------------------
oerp4556123450
oerp4556123470
I was trying the following... (4 Replies)
Discussion started by: baanprog
4 Replies
4. Shell Programming and Scripting
I have some files, those are abbreviated (ed,ea, and bi)
company_ed_20100719.txt
company_ea_20100719.txt
company_bi_20100719.txt
I would like to rename these files by replacing
ed with EmployeeDetails
ea with EmployeeAddress
bi with BankInfomration
as
company_... (3 Replies)
Discussion started by: LinuxLearner
3 Replies
5. Shell Programming and Scripting
Hi,
As a newbie, I'm desperate ro make my shell script work. I'd like a script which checks all the files in a directory, check the file name, if the file name ends with "extracted", store it in a variable, if it has a suffix of ".roi" stores in another variable. I'm going to use these two... (3 Replies)
Discussion started by: armando110
3 Replies
6. Shell Programming and Scripting
Hi ,
I am adding a line in my shell scripts to delete all the old directory with the below command. On running this command it is coming out with the message
find: incomplete statement
find /ersdg3/ERS/ERS_INPUT_LOGS/RIO/rio_archive -type d -mtime +47 -exec rm -rf {}
What is wrong or... (3 Replies)
Discussion started by: guddu_12
3 Replies
7. UNIX for Dummies Questions & Answers
Hello all,
I need to print directories using find command. The directories names contain date in the format YYYYMMDD or the name of directory is only the date format. I want print directories, which doesn't start with this date.
E.g I have dirs like
foo20120101
foo20120101foo
20120101foo... (1 Reply)
Discussion started by: satin1321
1 Replies
8. Shell Programming and Scripting
On my linux box, I have a file say dump.txt.
I then need to move to another seperte folder and need to find only one file with extension *.tar that has the closest timestamp after / next to the timestamp of the dump.txt. (2 Replies)
Discussion started by: mohtashims
2 Replies
9. Shell Programming and Scripting
As part of a bash the below line strips off a numerical prefix from directory 1 to search for in directory 2.
for file in /home/cmccabe/Desktop/comparison/missing/*.txt
do
file1=${file##*/} # Strip off directory
getprefix=${file1%%_*.txt}
... (5 Replies)
Discussion started by: cmccabe
5 Replies
10. UNIX for Beginners Questions & Answers
In a fastload teradata utility I am trying to delete the files which are older than 30days using the find and rm command as following.
find . -name 'xxx_*' -mtime +30 -exec rm -f {} \;
I expect it to delete all the files older than 30 days but sometimes it gives an error : find: bad status--... (3 Replies)
Discussion started by: stelkar
3 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)