06-30-2007
Quote:
Originally Posted by
jim mcnamara
One way:
Call ftw() - then in the "callback" function test the stat struct st_mode value with S_ISDIR().
Thanks for you prompt reply. I will try and report.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi
i have a cfg file,it contains
lpdma520.dev.ipc.us.aexp.com=SUBMCORE.REQUEST.FT
lpdma521.dev.ipc.us.aexp.com=SUBMCORE.REQUEST.FTREQ
lpdma522.dev.ipc.us.aexp.com=SUBMITSECUREFILEFLOW
i am retrieving the values using the function
RetrieveCfgvalue()
{
CFG_VALUE=`grep "$2="... (1 Reply)
Discussion started by: satish@123
1 Replies
2. Shell Programming and Scripting
when I do a df -k for a particular mount i get the result like this
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/ 4128448 3527496 391240 91% /
I need to extract the value 91 from this and use it in my script in an if condition. How will i do it Please advice. (8 Replies)
Discussion started by: codeman007
8 Replies
3. UNIX for Advanced & Expert Users
How will retrieve for a particular months file in UNIX say for example from January to February 2008. (1 Reply)
Discussion started by: rajesh08
1 Replies
4. UNIX for Dummies Questions & Answers
Hi,
We run an IMAP server at work. I had to move the home directory of one user to another partition. I updated his account in /etc/passwd. For some reason his Microsoft Outlook account cannot rertrieve his new emails. I check /var/spool/mail and his emails are there...
Any advice? (1 Reply)
Discussion started by: mojoman
1 Replies
5. Shell Programming and Scripting
hello,
I have a file that have lines that contains xml tags. for each line, i want to retrieve the value from the following xml tags and output it to another file with the values only, comma seperated. what is the best way to do this? again, the string is all in 1 line one, though it has many... (9 Replies)
Discussion started by: davidsouk
9 Replies
6. Shell Programming and Scripting
Hi,
I have a file abcd.txt which has contents in the form of full path file names i.e.
$home> vi abcd.txt
/a/b/c/r1.txt
/q/w/e/r2.txt
/z/x/c/r3.txt
Now I want to retrieve only the directory path name for each row
i.e
/a/b/c/
/q/w/e/
How to get the same through shell script?... (7 Replies)
Discussion started by: royzlife
7 Replies
7. Shell Programming and Scripting
Hi,
i am writing a shell script that will execute a select query. the select query returns one specific value.
Idql is used for quering in documentum...
X = $ (idql <docbase> -U<username> -<pwd> -Rdqlqueryfile.dql << !
set heading off
set footer off
!)
query in dqlqueryfile is... (0 Replies)
Discussion started by: kichu
0 Replies
8. Shell Programming and Scripting
Hi,
I have a file say file1.ksh. Which has data like:
ifile $AI_SERIAL/$FILE.DAT...
ofile $AI_SERIAL/feed.dat...
My requirement is to find the count of all the lines which does not have $ after /. So i have written the code:
grep -w 'AI_SERIAL' file1.ksh | cut -d '/' -f2 | grep... (9 Replies)
Discussion started by: Kamna
9 Replies
9. Shell Programming and Scripting
hi,
i have some file in a directory say
p1.txt.201305051200.lst
p1.txt.201305051300.lst
p1.txt.201306051200.lst
p1.txt.201306051300.lst
p2.txt.201306051200.lst
p2.txt.201306051300.lst
i am using p* pattern to retrieve these file
ls -1 p*
the files in red color are the latest... (7 Replies)
Discussion started by: Little
7 Replies
10. Shell Programming and Scripting
I have this in log file /var/log/maillog
XXX YYY ZZZ :15214 I=:25 AAA BBB CCC
I need awk/sed operation on this, so that it retrieves only the first IP.
cat /var/log/maillog | sed_operation
55.66.77.88 (2 Replies)
Discussion started by: anil510
2 Replies
FTW(3) BSD Library Functions Manual FTW(3)
NAME
ftw, nftw -- traverse (walk) a file tree
SYNOPSIS
#include <ftw.h>
int
ftw(const char *path, int (*fn)(const char *, const struct stat *ptr, int flag), int depth);
int
nftw(const char *path, int (*fn)(const char *, const struct stat *ptr, int flag, struct FTW *), int depth, int flags);
DESCRIPTION
These functions are provided for compatibility with legacy code. New code should use the fts(3) functions.
The ftw() and nftw() functions traverse (walk) the directory hierarchy rooted in path. For each object in the hierarchy, these functions
call the function pointed to by fn. The ftw() function passes this function a pointer to a NUL-terminated string containing the name of the
object, a pointer to a stat structure corresponding to the object, and an integer flag. The nftw() function passes the aforementioned argu-
ments plus a pointer to a FTW structure as defined by <ftw.h> (shown below):
struct FTW {
int base; /* offset of basename into pathname */
int level; /* directory depth relative to starting point */
};
Possible values for the flag passed to fn are:
FTW_F A regular file.
FTW_D A directory being visited in pre-order.
FTW_DNR A directory which cannot be read. The directory will not be descended into.
FTW_DP A directory being visited in post-order (nftw() only).
FTW_NS A file for which no stat(2) information was available. The contents of the stat structure are undefined.
FTW_SL A symbolic link.
FTW_SLN A symbolic link with a non-existent target (nftw() only).
The ftw() function traverses the tree in pre-order. That is, it processes the directory before the directory's contents.
The depth argument specifies the maximum number of file descriptors to keep open while traversing the tree. It has no effect in this imple-
mentation.
The nftw() function has an additional flags argument with the following possible values:
FTW_PHYS Physical walk, don't follow symbolic links.
FTW_MOUNT The walk will not cross a mount point.
FTW_DEPTH Process directories in post-order. Contents of a directory are visited before the directory itself. By default, nftw() traverses
the tree in pre-order.
FTW_CHDIR Change to a directory before reading it. By default, nftw() will change its starting directory. The current working directory
will be restored to its original value before nftw() returns.
RETURN VALUES
If the tree was traversed successfully, the ftw() and nftw() functions return 0. If the function pointed to by fn returns a non-zero value,
ftw() and nftw() will stop processing the tree and return the value from fn. Both functions return -1 if an error is detected.
ERRORS
The ftw() and nftw() functions may fail and set errno for any of the errors specified for the library functions close(2), open(2), stat(2),
malloc(3), opendir(3) and readdir(3). If the FTW_CHDIR flag is set, the nftw() function may fail and set errno for any of the errors speci-
fied for chdir(2). In addition, either function may fail and set errno as follows:
[EINVAL] The depth argument is less than 1 or greater than OPEN_MAX.
LEGACY ERRORS
The ftw() and nftw() functions are far more tolerant of symlink cycles and are lax in reporting errors while accessing the initial path.
When nftw() is passed FTW_MOUNT, it will pass the mount point to the callback function.
SEE ALSO
chdir(2), close(2), open(2), stat(2), fts(3), malloc(3), opendir(3), readdir(3), compat(5)
STANDARDS
The ftw() and nftw() functions conform to IEEE Std 1003.1-2001 (``POSIX.1'') and Version 3 of the Single UNIX Specification (``SUSv3'').
HISTORY
Prior to MacOS X 10.4 ftw did not follow symlinks.
BUGS
The depth argument is currently ignored.
BSD
May 20, 2003 BSD