Sponsored Content
Top Forums UNIX for Advanced & Expert Users Tip: how to get the deepest directories Post 302978386 by Don Cragun on Friday 29th of July 2016 01:50:18 PM
Old 07-29-2016
The POSIX standards don't require a directory to contain directory entries for dot and dot-dot. I assume that any filesystem type that does not include entries for dot and dot-dot would have a link count of 0 (not 2) for an empty directory.

But, I have never used a filesystem type that does not contain entries for dot and dot-dot. Does anyone know if any of these filesystems still exist?
This User Gave Thanks to Don Cragun For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

check if multiple directories exist else create missing directories

Hi , I 'm trying to check if multiple directories exist on a server, if not create the missing ones and print " creating missing directory. how to write this in a simple script, I have made my code complex if ; then taskStatus="Schema extract directory exists, checking if SQL,Count and... (7 Replies)
Discussion started by: ramky79
7 Replies

2. Shell Programming and Scripting

Script for parsing directories one level and finding directories older than n days

Hello all, Here's the deal...I have one directory with many subdirs and files. What I want to find out is who is keeping old files and directories...say files and dirs that they didn't use since a number of n days, only one level under the initial dir. Output to a file. A script for... (5 Replies)
Discussion started by: ejianu
5 Replies

3. Shell Programming and Scripting

How to list all the directories, sub directories in a mount along with size in ascending order?

Hi , I am very new to unix as well as shell scripting. I have to write a script for the following requirement. In a particular mount, have to list all the directories and sub directories along with size of the directory and sub directory in ascending order. Please help me in this regard and many... (4 Replies)
Discussion started by: nmakkena
4 Replies

4. UNIX for Dummies Questions & Answers

Using grep command to find the pattern of text in all directories and sub-directories.

Hi all, Using grep command, i want to find the pattern of text in all directories and sub-directories. e.g: if i want to search for a pattern named "parmeter", i used the command grep -i "param" ../* is this correct? (1 Reply)
Discussion started by: vinothrajan55
1 Replies

5. Shell Programming and Scripting

How to list all the files, directories and sub-directories in the current path except one directory?

Can anyone come up with a unix command that lists all the files, directories and sub-directories in the current directory except a folder called log.? Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies

6. UNIX for Dummies Questions & Answers

List the directories, having given pattern in the directories name, sorted by creation date

It is for HP-Unix B.11.31. Requirement: 1. List the directories, having given pattern in the directories name, sorted by creation date. Example: Directories with name "pkg32*" or "pkg33*" 2. On the output of 1. list the directories by creation date as sort order, with creation date... (2 Replies)
Discussion started by: Siva SQL
2 Replies

7. UNIX for Advanced & Expert Users

Tip: show the last 3 directories in the shell prompt

tcsh: have the following in .cshrc (or .tcshrc) set prompt=": " zsh: have the following in .zshrc PS1="%# " bash: have the following in .bashrc PS1='\$ 'Lacking direct support this is a good approximation. (0 Replies)
Discussion started by: MadeInGermany
0 Replies

8. Solaris

Giving read write permission to user for specific directories and sub directories.

I have searched this quite a long time but couldn't find the right method for me to use. I need to assign read write permission to the user for specific directories and it's sub directories and files. I do not want to use ACL. This is for Solaris. Please help. (1 Reply)
Discussion started by: blinkingdan
1 Replies

9. UNIX for Beginners Questions & Answers

[Tip] Housekeeping Tasks Made Easy - User Home directories and Leftover Files

We have regularly questions about how to create users and user accounts. But regularly user accounts need to be deleted too. It is quite easy to delete the user account itself but usually the HOME directory of the user remains. It is good style to remove these directories but simply deleting... (3 Replies)
Discussion started by: bakunin
3 Replies
DIRENT(3)						   BSD Library Functions Manual 						 DIRENT(3)

NAME
dirent -- directory format SYNOPSIS
#include <sys/types.h> #include <sys/dirent.h> mode DTTOIF(dirtype); dirtype IFTODT(mode); DESCRIPTION
Directories provide a convenient hierarchical method of grouping files while obscuring the underlying details of the storage medium. A directory file is differentiated from a plain file by a flag in its inode(5) entry. It consists of records (directory entries) each of which contains information about a file and a pointer to the file itself. Directory entries may contain other directories as well as plain files; such nested directories are referred to as subdirectories. A hierarchy of directories and files is formed in this manner and is called a file system (or referred to as a file system tree). Each directory file contains two special directory entries; one is a pointer to the directory itself called dot '.' and the other a pointer to its parent directory called dot-dot '..'. Dot and dot-dot are valid pathnames, however, the system root directory '/', has no parent and dot-dot points to itself like dot. File system nodes are ordinary directory files on which has been grafted a file system object, such as a physical disk or a partitioned area of such a disk. (See mount(8).) IMPLEMENTATION NOTES
The directory entry format is defined in the file <sys/dirent.h>, which is also included by <dirent.h>. The format is represented by the dirent structure, which contains the following entries: ino_t d_fileno; uint16_t d_reclen; uint16_t d_namlen; uint8_t d_type; char d_name[MAXNAMLEN + 1]; These are: 1. The d_fileno entry is a number which is unique for each distinct file in the filesystem. Files that are linked by hard links (see link(2)) have the same d_fileno. If d_fileno is zero, the entry refers to a deleted file. The type ino_t is defined in <sys/types.h>. 2. The d_reclen entry is the length, in bytes, of the directory record. 3. The d_namlen entry specifies the length of the file name excluding the NUL. Thus the actual size of d_name may vary from 1 to MAXNAMLEN + 1. 4. The d_type is the type of the file. 5. The d_name entry contains a NUL-terminated file name. The following table lists the types available for d_type and the corresponding ones used in the struct stat (see stat(2)), respectively: Dirent Stat Description DT_UNKNOWN - unknown file type DT_FIFO S_IFIFO named pipe DT_CHR S_IFCHR character device DT_DIR S_IFDIR directory DT_BLK S_IFBLK block device DT_REG S_IFREG regular file DT_LNK S_IFLNK symbolic link DT_SOCK S_IFSOCK UNIX domain socket DT_WHT S_IFWHT dummy ``whiteout inode'' The DT_WHT type is internal to the implementation and should not be seen in normal user applications. The macros DTTOIF() and IFTODT() can be used to convert from struct dirent types to struct stat types, and vice versa. COMPATIBILITY
The IEEE Std 1003.1-2001 (``POSIX.1'') standard specifies only the fields d_ino and d_name. The remaining fields are available on many, but not all systems. Furthermore, the standard leaves the size of d_name as unspecified, mentioning only that the number of bytes preceding the terminating NUL shall not exceed NAME_MAX. Because of this, and because the d_namlen field may not be present, a portable application should determine the size of d_name by using strlen(3) instead of applying the sizeof() operator. SEE ALSO
getdents(2), fs(5), inode(5) HISTORY
A dir structure appeared in Version 7 AT&T UNIX. The dirent structure appeared in NetBSD 1.3. BSD
May 16, 2010 BSD
All times are GMT -4. The time now is 11:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy