Sponsored Content
Top Forums UNIX for Dummies Questions & Answers To find the latest modified file in a directory Post 302869373 by RudiC on Wednesday 30th of October 2013 07:27:28 AM
Old 10-30-2013
That pipe doesn't cause any problem on my linux. What be your system?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script to find latest executable in particular directory and start that particular ex

i have a directory in which there are executable files and these files are added at runtime. now i need a shell script which will be called at a certain interval. this shell script should find the latest executable file in that directory and start that executable. care should be taken that once the... (6 Replies)
Discussion started by: kvineeth
6 Replies

2. Shell Programming and Scripting

perl find directory only if modified in last hour

I want a one liner perl command to find a directory only if the modified time is within the last hour I am running this on windows - and I will define a variable for the result. So for example I want to return value of 1 for the variable if the modified time of d:\test1 is within the last... (0 Replies)
Discussion started by: frustrated1
0 Replies

3. Shell Programming and Scripting

Find the directory modified/created before 4 days

Hi, I have an application which creates some directories while running. I want to delete these directories which are 4 days older. i tried find . type d -mtime +1 -print And it is working fine.. but find . type d -mtime +4 -print is not giving any results which are 4 days... (6 Replies)
Discussion started by: Tuxidow
6 Replies

4. Shell Programming and Scripting

How to find the latest modified file from the unix server.

hi Friends, In my directory i have some files. I need to find out latest modified file. Please help me. Sreenu. (2 Replies)
Discussion started by: sreenu80
2 Replies

5. UNIX for Dummies Questions & Answers

How to get the latest modified file name in /home directory?

I only know how to list all sub-directories or files in specified directory. I don't know how to order them by modified date, furthermore, I don't know how to get the top one file in the sorted list. Wish you can do me a favor. Thanks in advance! (3 Replies)
Discussion started by: crest.boy
3 Replies

6. Shell Programming and Scripting

Move the latest or older File from one directory to another Directory

I Need help for one requirement, I want to move the latest/Older file in the folder to another file. File have the datetimestamp in postfix. Example: Source Directory : \a destination Directory : \a\b File1 : xy_MMDDYYYYHHMM.txt (xy_032120101456.txt) File2: xy_MMDDYYYYHHMM.txt... (1 Reply)
Discussion started by: pp_ayyanar
1 Replies

7. Shell Programming and Scripting

find the latest files in multiple directory

I want to get the latest files from multiple directories, d1, d2,d3 and d4 under the parent dierectoy d. can anyone help out with this? thx (3 Replies)
Discussion started by: shyork2001
3 Replies

8. Shell Programming and Scripting

Find the latest directory and loop through the files and pick the error messages

Hi, I am new to unix and shell scripting,can anybody help me in sctipting a requirement. my requirement is to get the latest directory the name of the directory will be like CSB.monthdate_time stamp like CSB.Sep29_11:16 and CSB.Oct01_16:21. i need to pick the latest directory. in the... (15 Replies)
Discussion started by: sudhir_83k
15 Replies

9. Shell Programming and Scripting

to pick the latest file modified in a directory

I wan to pick the latest modified file name and redirect it to a file .. ls -tr | tail -1 >file but this is printing file ins side the filename , can anyone help me out (5 Replies)
Discussion started by: vishwakar
5 Replies

10. Shell Programming and Scripting

Help with finding the latest modified version of a file within directories

I am trying to look into multiple directories and pluck out the latest version of a specific file, regardless of where it sits within the directory structure. Ex: The file is a .xls file and could have a depth within the directory of anywhere from 1-5 Working directory - Folder1... (6 Replies)
Discussion started by: co21ss
6 Replies
FIND(1) 						      General Commands Manual							   FIND(1)

NAME
find - find files SYNOPSIS
find pathname-list expression find pattern DESCRIPTION
In the first form above, find recursively descends the directory hierarchy for each pathname in the pathname-list (i.e., one or more path- names) seeking files that match a boolean expression written in the primaries given below. In the descriptions, the argument n is used as a decimal integer where +n means more than n, -n means less than n and n means exactly n. The second form rapidly searches a database for all pathnames which match pattern. Usually the database is recomputed weekly and contains the pathnames of all files which are publicly accessible. If escaped, normal shell "globbing" characters (`*', `?', `[', and ']') may be used in pattern, but the matching differs in that no characters (e.g. `/') have to be matched explicitly. As a special case, a simple pat- tern containing no globbing characters is matched as though it were *pattern*; if any globbing character appears there are no implicit globbing characters. -name filename True if the filename argument matches the current file name. Normal shell argument syntax may be used if escaped (watch out for `[', `?' and `*'). -perm onum True if the file permission flags exactly match the octal number onum (see chmod(1)). If onum is prefixed by a minus sign, more flag bits (017777, see stat(2)) become significant and the flags are compared: (flags&onum)==onum. -type c True if the type of the file is c, where c is b, c, d, f, l or s for block special file, character special file, directory, plain file, symbolic link, or socket. -links n True if the file has n links. -user uname True if the file belongs to the user uname (login name or numeric user ID). -nouser True if the file belongs to a user not in the /etc/passwd database. -group gname True if the file belongs to group gname (group name or numeric group ID). -nogroup True if the file belongs to a group not in the /etc/group database. -size n True if the file is n blocks long (512 bytes per block). -inum n True if the file has inode number n. -atime n True if the file has been accessed in n days. -mtime n True if the file has been modified in n days. -exec command True if the executed command returns a zero value as exit status. The end of the command must be punctuated by an escaped semi- colon. A command argument `{}' is replaced by the current pathname. -ok command Like -exec except that the generated command is written on the standard output, then the standard input is read and the command executed only upon response y. -print Always true; causes the current pathname to be printed. -ls Always true; causes current pathname to be printed together with its associated statistics. These include (respectively) inode number, size in kilobytes (1024 bytes), protection mode, number of hard links, user, group, size in bytes, and modification time. If the file is a special file the size field will instead contain the major and minor device numbers. If the file is a symbolic link the pathname of the linked-to file is printed preceded by ``->''. The format is identical to that of ``ls -gilds'' (note however that formatting is done internally, without executing the ls program). -newer file True if the current file has been modified more recently than the argument file. -cpio file Write the current file on the argument file in cpio format. -xdev Always true; causes find not to traverse down into a file system different from the one on which current argument pathname resides. 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 find all accessible files whose pathname contains `find': find find To typeset all variants of manual pages for `ls': vtroff -man `find '*man*/ls.?'` 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 {} ; FILES
/etc/passwd /etc/group /var/db/find.codes coded pathnames database SEE ALSO
sh(1), test(1), fs(5) Relevant paper in February, 1983 issue of ;login:. BUGS
The first form's syntax is painful, and the second form's exact semantics is confusing and can vary from site to site. More than one `-newer' option does not work properly. 7th Edition October 11, 1996 FIND(1)
All times are GMT -4. The time now is 01:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy