10-01-2010
"find" isn't going to do what you want it to. It doesn't keep track of concepts like "newest". If you had a file that was, say, created by the last run of whatever you're tracing, you could use the --newer flags to find directories created after that point, but you would still get more than one, likely. You would get all the directories created after that point in time.
This is usually where I would write a small c program calling ftw, or write something in perl (or whatever your favorite scripting language is) to stat each directory and keep track of their timestamp (you would want mtime, likely) and then emit the most recent one.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Script Experts,
Here is my scenario:
1. /var/mqm/qmgrs folder will contain 11 folders as follows:
1. /var/mqm/qmgrs/Folder_Name1
....................../Folder_Name2
....................../Folder_Name3
.......
...................../Folder_Name11
2. if Folder_Name1 exists... (5 Replies)
Discussion started by: hkhan12
5 Replies
2. UNIX for Dummies Questions & Answers
Hi,
I have a problem.
I have some text files in a folder. The names can be like:
emp_20080307053015.dat
emp_20080306053015.dat
emp_20080305053015.dat
emp_20080304053015.dat
The date format appended is like yyyymmdd and timestamp.
What i need is i have to copy the latest file every... (3 Replies)
Discussion started by: Aswarth
3 Replies
3. Shell Programming and Scripting
Hello all, this is my first post while i am trying to understand unix.
I would basically like to know if i can do this:
Lets say i have a folderA and folderB
And i save something in folderA
Can i make a script that checks folderA latest file, then compares it with the date of latest file in... (16 Replies)
Discussion started by: takissd
16 Replies
4. Shell Programming and Scripting
Hi all,
*I use Uwin and Cygwin emulator.
I´m trying to search for all text files in the current folder (C/Files) and its sub folders using
find -depth -name "*.txt"
The above command worked for me, but now I would like to copy all found text files to a new folder (C/Files/Text) with ... (4 Replies)
Discussion started by: cgkmal
4 Replies
5. Shell Programming and Scripting
Hi all I'm new to your forum but not new to shells. I'm having a little trouble though as it's been quite some time since I scripted. Here's what I'm trying to do:
I'm trying to search a directory named '/var/root/Applications' for another directory 'fooBar'. The "Applications" directory... (9 Replies)
Discussion started by: DC Slick
9 Replies
6. UNIX for Dummies Questions & Answers
#!/bin/bash
for i in {1..1536..1}
do
#find /home/test/Desktop/up111/workplace/Malware/$i/logs
for a in /home/test/Desktop/up111/workplace/Malware/$i/logs/*
do
#max=a
for b in /home/test/Desktop/up111/workplace/Malware/$i/logs/*
do
... (4 Replies)
Discussion started by: upvan111
4 Replies
7. UNIX and Linux Applications
Hi All,
One job in unix server will generate .csv files daily. I need to copy the latest of these .csv file from the unix server to the shared drive/folder in windows through unix script. My shared folder will look something like
W:\some folder(for example). Could any one of you please help... (3 Replies)
Discussion started by: jaya@123
3 Replies
8. Shell Programming and Scripting
Hello Expert,
I have a strange requirement,
I have folder where weekly backup are taken...
week1_bkup_02102011
week2_bkup_09102011
week3_bkup_16102011
.
.
everyweek a backup is created
I want to delete all folder except latest one
for example in above a week4_bkup_23102011 is added... (3 Replies)
Discussion started by: aks_1902
3 Replies
9. Shell Programming and Scripting
HI
I have folder in home dir.
/home/kpp/07222013
/home/kpp/07212013
/home/kpp/07202013
Output :--
/home/kpp/07222013
Just find latest date (5 Replies)
Discussion started by: pareshkp
5 Replies
10. UNIX for Beginners Questions & Answers
HI Guys,
Can anyone help me to retrieve the latest file from below example using SFTP
I have below list of files in a folder
v403t.lstprgms.sortin1
val027.d099.fwest.oct2711
xcelrptd.d1400sqp.dec1713.t040459.@02del
xcelrptd.d1400sqp.dec1713.t073308.@02del... (3 Replies)
Discussion started by: heye18
3 Replies
LEARN ABOUT OPENSOLARIS
ftw
ftw.h(3HEAD) Headers ftw.h(3HEAD)
NAME
ftw.h, ftw - file tree traversal
SYNOPSIS
#include <ftw.h>
DESCRIPTION
The <ftw.h> header defines the FTW structure that includes the following members:
int base
int level
The <ftw.h> header defines macros for use as values of the third argument to the application-supplied function that is passed as the sec-
ond argument to ftw() and nftw() (see ftw(3C)):
FTW_F file
FTW_D directory
FTW_DNR directory without read permission
FTW_DP directory with subdirectories visited
FTW_NS unknown type; stat() failed
FTW_SL symbolic link
FTW_SLN symbolic link that names a nonexistent file
The <ftw.h> header defines macros for use as values of the fourth argument to nftw():
FTW_PHYS Physical walk, does not follow symbolic links. Otherwise, nftw() follows links but does not walk down any path that crosses
itself.
FTW_MOUNT The walk does not cross a mount point.
FTW_DEPTH All subdirectories are visited before the directory itself.
FTW_CHDIR The walk changes to each direct ory before reading it.
The <ftw.h> header defines the stat structure and the symbolic names for st_mode and the file type test macros as described in
<sys/stat.h>.
Inclusion of the <ftw.h> header might also make visible all symbols from <sys/stat.h>.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO
ftw(3C), stat.h(3HEAD), attributes(5), standards(5)
SunOS 5.11 10 Sep 2004 ftw.h(3HEAD)