Sponsored Content
Operating Systems HP-UX Getting the index of the last entry in a directory Post 302327598 by psimoes79 on Monday 22nd of June 2009 08:04:06 AM
Old 06-22-2009
Getting the index of the last entry in a directory

Hello,

Is there anyway of getting the index of the last entry in a directory? I'm using a C program to read the entries, but I want to go to the last entry because the directory is very big and I don't want to read all. I was using the size of the directory file descriptor but when I remove files the size doesn't decrease. Any ideas? Thanks.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

tcsh + completing a sub-directory entry

As part of a script Im designing, I am required to allow the command line to finish off part of a series of sub-directory entries. Basically what I want to do is cp /root/parent/part of subs name + other part of subs name/file /other_root/other_parent/other_sub/file without facing... (0 Replies)
Discussion started by: JamesGoh
0 Replies

2. Filesystems, Disks and Memory

why the inode index of file system starts from 1 unlike array index(0)

why do inode indices starts from 1 unlike array indexes which starts from 0 its a question from "the design of unix operating system" of maurice j bach id be glad if i get to know the answer quickly :) (0 Replies)
Discussion started by: sairamdevotee
0 Replies

3. UNIX for Dummies Questions & Answers

wh inode index starts from 1 unlike array index (0)

brothers why inode index starts from 1 unlike array inex which starts from 0 its a question from the design of unix operating system of maurice j.bach i need to know the answer urgently...someone help please (1 Reply)
Discussion started by: sairamdevotee
1 Replies

4. Shell Programming and Scripting

Unix script to detect new file entry in directory

Hi All, I want to detect each new file coming / getting created in unix directory. When every new file came to directory, i have to get its details like its size , date and time stamp and store it into another file. Could any one please tell me , how i can achieve that? Thanks. (13 Replies)
Discussion started by: james_1984
13 Replies

5. Shell Programming and Scripting

Sort from start index and end index in line

Hi All, I have a file (FileNames.txt) which contains the following data in it. $ cat FileNames.txt MYFILE17XXX208Sep191307.csv MYFILE19XXX208Sep192124.csv MYFILE20XXX208Sep192418.csv MYFILE22XXX208Sep193234.csv MYFILE21XXX208Sep193018.csv MYFILE24XXX208Sep194053.csv... (5 Replies)
Discussion started by: krish_indus
5 Replies

6. Shell Programming and Scripting

Run SED for all index.jsp files across a directory structure.

Hi, I am a novice and require help once again. I have a over 200 file all called index.jsp placed in different directories The following Sed command gives me the data of all included jsp files in index.jsp sed -n -e 's/^.*page="\(*\).*$/\1/p' index.jsp How can I run the above... (6 Replies)
Discussion started by: rajkdutta
6 Replies

7. UNIX for Dummies Questions & Answers

Not able to delete this file/directory/entry

Hello UNIX gurus, I noticed this file or whatever in one of our directories, and somehow I am not able to proceed with my work, without deleting this one. .insert--- 1 siebload intrface 0 Feb 22 01:25 Testfile I am confused, as it doesnt appear to be a file, and on doing any... (2 Replies)
Discussion started by: ppathak1234
2 Replies

8. Web Development

Directory index forbidden by Options directive error on specific directory with indexing disabled

I am seeing the following error appear numerous times in my Apache error log: I have my Apache config configured as below, so I would expect indexing not to occur on this directory as it falls under the parent /web directory. Strangely all the IP address, including this example, all... (5 Replies)
Discussion started by: crmpicco
5 Replies

9. Shell Programming and Scripting

Shell script to find if any new entry in directory

I require a shell script to find if any new entry of dump files present in a particular directory and to send an email if any new entry exists.I had a crontab to run the script for every 5 min. Below are the file names.dump.20150327.152407.12058630.0002.phd.gz... (9 Replies)
Discussion started by: bhas85
9 Replies

10. AIX

Automate DIRECTORY ENTRY when in remote SHELL

Good day all I am trying to figure out how to automate the command in a shell script that i have written. Some context: The script does the following on the local host #!/bin/sh banner 'QikCopy' echo "Please insert file name for SCP command!" read file DUMMY scp -p $file... (2 Replies)
Discussion started by: MrRobot
2 Replies
getdents(2)							   System Calls 						       getdents(2)

NAME
getdents - read directory entries and put in a file system independent format SYNOPSIS
#include <dirent.h> int getdents(int fildes, struct dirent *buf, size_t nbyte); DESCRIPTION
The getdents() function attempts to read nbyte bytes from the directory associated with the file descriptor fildes and to format them as file system independent directory entries in the buffer pointed to by buf. Since the file system independent directory entries are of vari- able lengths, in most cases the actual number of bytes returned will be less than nbyte. The file system independent directory entry is specified by the dirent structure. See dirent.h(3HEAD). On devices capable of seeking, getdents() starts at a position in the file given by the file pointer associated with fildes. Upon return from getdents(), the file pointer is incremented to point to the next directory entry. RETURN VALUES
Upon successful completion, a non-negative integer is returned indicating the number of bytes actually read. A return value of 0 indicates the end of the directory has been reached. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The getdents() function will fail if: EBADF The fildes argument is not a valid file descriptor open for reading. EFAULT The buf argument points to an illegal address. EINVAL The nbyte argument is not large enough for one directory entry. EIO An I/O error occurred while accessing the file system. ENOENT The current file pointer for the directory is not located at a valid entry. ENOLINK The fildes argument points to a remote machine and the link to that machine is no longer active. ENOTDIR The fildes argument is not a directory. EOVERFLOW The value of the dirent structure member d_ino or d_off cannot be represented in an ino_t or off_t. USAGE
The getdents() function was developed to implement the readdir(3C) function and should not be used for other purposes. The getdents() function has a transitional interface for 64-bit file offsets. See lf64(5). SEE ALSO
readdir(3C), dirent.h(3HEAD), lf64(5) SunOS 5.10 17 Jul 2001 getdents(2)
All times are GMT -4. The time now is 11:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy