I was hoping to get some assistance with this C program I am working on. The goal is to find the largest file in the current directory and then display this filename along with the filesize. What I have so far will display all the files in the current directory. But, how do I deal with "grabbing" and displaying the filesize?
So far:
Shouldn't something like this work for filesize? It doesn't print the correct size.
Any help would be greatly appreciated.
Hi,
I am unable to see all files in a current directory when use "ls -lrt" command
it is giving error message as below ( I think this current directory is having about 500 files)
<CONTROL /home/ckanth/sri>ls -lrt
UX:ls: ERROR: Out of memory: Insufficient or invalid memory
But when i... (3 Replies)
I'm trying to come up with a way of finding largest directories in a filesystem (let's say filesystems is running ot of space and I need to find what is consuming all the space). If a directory is a single filesystem, then it's easy, I just run "du -sk *| sort -nr". But the problem is, if some... (8 Replies)
Hi Gurus,
I have a directory A, which has some 0 byte files in it.
This directory also has a subdirectory B which also has some 0 byte files in it.
The problem:
I only need to find out the names of the 0 byte files in the directory A.
I'm using the following command
find . -name *.zip... (6 Replies)
hello all.
i would like to be able to find the names of all files on a remote machine using ssh.
i only want the names of files, not directories
so far i'm stuck at "du -a | sort -n"
also, is it possible to write them to a file on my machine? i know how to write it to a file on that... (2 Replies)
Hello,
How to find the list of 5 largest(size wise) file in current directory?i tried using
ls -l | sort -t " " -r +5 -6 -n | head -5
but this is not giving correct output as ls -l command gives 1 extra line of output that is how many total files are there!so by running the above... (4 Replies)
Hi All
I was wondering what is the most efficient way to find files in the current directory(that may contain 100,000's files), that meets a certain specified file type and of a certain age.
I have experimented with the find command in unix but it also searches all sub directories. I have... (2 Replies)
What is the best way to find the largest files in a directory? I used du -k|sort -rn |less.
I got a results for this. But if I used the following command , I got another result...a different order in the same directory. Why is that?
ls -la |awk '{print $5," ",$9}' sort -rn|less. I saw that... (6 Replies)
Hi Experts,
1. In unix how to list the largest file in given directory.
The answer will in single line statement.
2. I have Sun solaris live CD .I try to compile sample c program using "CC compiler".But its shows "cc command not found".
Please help on this.
Thanks in advance.... (4 Replies)
Hi All,
I am trying to find 4 latest files inside one folder having following File Name pattern and store them into 4 different variables and then use for processing in my shell script. File name is fixed length.
1) Each file starts with = ABCJmdmfbsjop letters + 7 Digit Number... (6 Replies)
Good evening.
because the folder has thousand of files it takes too long and have some trouble to get the largest files and then compress files or delete it, for instance
find . -size +10000000c -exec ls -ld {} \; |sort -k5n | grep -v .gz
The above commad took an hour and i have to cancel... (10 Replies)
Discussion started by: alexcol
10 Replies
LEARN ABOUT POSIX
dirent.h
<dirent.h>(P) POSIX Programmer's Manual <dirent.h>(P)
NAME
dirent.h - format of directory entries
SYNOPSIS
#include <dirent.h>
DESCRIPTION
The internal format of directories is unspecified.
The <dirent.h> header shall define the following type:
DIR A type representing a directory stream.
It shall also define the structure dirent which shall include the following members:
ino_t d_ino File serial number.
char d_name[] Name of entry.
The type ino_t shall be defined as described in <sys/types.h> .
The character array d_name is of unspecified size, but the number of bytes preceding the terminating null byte shall not exceed {NAME_MAX}.
The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.
int closedir(DIR *);
DIR *opendir(const char *);
struct dirent *readdir(DIR *);
int readdir_r(DIR *restrict, struct dirent *restrict,
struct dirent **restrict);
void rewinddir(DIR *);
void seekdir(DIR *, long);
long telldir(DIR *);
The following sections are informative.
APPLICATION USAGE
None.
RATIONALE
Information similar to that in the <dirent.h> header is contained in a file <sys/dir.h> in 4.2 BSD and 4.3 BSD. The equivalent in these
implementations of struct dirent from this volume of IEEE Std 1003.1-2001 is struct direct. The filename was changed because the name
<sys/dir.h> was also used in earlier implementations to refer to definitions related to the older access method; this produced name con-
flicts. The name of the structure was changed because this volume of IEEE Std 1003.1-2001 does not completely define what is in the struc-
ture, so it could be different on some implementations from struct direct.
The name of an array of char of an unspecified size should not be used as an lvalue. Use of:
sizeof(d_name)
is incorrect; use:
strlen(d_name)
instead.
The array of char d_name is not a fixed size. Implementations may need to declare struct dirent with an array size for d_name of 1, but the
actual number of characters provided matches (or only slightly exceeds) the length of the filename.
FUTURE DIRECTIONS
None.
SEE ALSO
<sys/types.h> , the System Interfaces volume of IEEE Std 1003.1-2001, closedir(), opendir(), readdir(), readdir_r(), rewinddir(),
seekdir(), telldir()
COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol-
ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE
and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained
online at http://www.opengroup.org/unix/online.html .
IEEE /The Open Group 2003 <dirent.h>(P)