Sponsored Content
Top Forums Shell Programming and Scripting using c programming in unix to delete zero-byte files in a specified directory Post 302347499 by ryandegreat25 on Tuesday 25th of August 2009 10:27:57 PM
Old 08-25-2009
i believe school assignment is not allowed, it defeats the purpose of self studying.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

finding 0 byte files in current directory only

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)
Discussion started by: ramky79
6 Replies

2. Shell Programming and Scripting

Check if 2 files are identical byte-to-byte?

In my server migration requirement, I need to compare if one file on old server is exactly the same as the corresponding file on the new server. For diff and comm, the inputs need to be sorted. But I do not want to disturb the content of the file and need to find byte-to-byte match. Please... (4 Replies)
Discussion started by: krishmaths
4 Replies

3. Shell Programming and Scripting

delete zero byte file

Hello I have a requirement where i need to find the zero byte size file in the directory and need to delete that zero byte file. Thanks (2 Replies)
Discussion started by: dsdev_123
2 Replies

4. Shell Programming and Scripting

Delete all files if another files in the same directory has a matching occurence of a specific word

Hello, I have several files in a specific directory. A specific string in one file can occur in another files. If this string is in other files. Then all the files in which this string occured should be deleted and only 1 file should remain with the string. Example. file1 ShortName "Blue... (2 Replies)
Discussion started by: premier_de
2 Replies

5. UNIX for Dummies Questions & Answers

Want to delete a directory on a Unix-Webserver

Hi folks, I want to delete a folder on my webserver via ftp, but the server said "Operation not permitted". So I want to delete the folder via ssh - not successfull. This is what I have done and what the server said: --------------------------- rmdir views rmdir: views: Directory not... (12 Replies)
Discussion started by: Lkwjoe
12 Replies

6. UNIX for Dummies Questions & Answers

How does unix system administration, unix programming, unix network programming differ?

How does unix system administration, unix programming, unix network programming differ? Please help. (0 Replies)
Discussion started by: thulasidharan2k
0 Replies

7. UNIX for Dummies Questions & Answers

delete unix directory

I installed membersgear into my website and decided it was not right for me. I issued rm -r on directory membersgear and it deleted everything except the subdirectory templates_c. I have found several directories in this directory which are named like %%114. Ownership on these directories... (5 Replies)
Discussion started by: pdinardo
5 Replies

8. UNIX for Dummies Questions & Answers

Cannot delete files and directory

hello i am trying to delete some files and also some directories. However, despite having the required permissions (i m the owner), Permission is being denied. I also tried to delete using find and inode number, but again Permission was denied. :wall: I am new to unix so please dumb down... (8 Replies)
Discussion started by: curiosity
8 Replies

9. Shell Programming and Scripting

Delete all files if another files in the same directory has a matching occurrence of a specific word

he following are the files available in my directory RSK_123_20141113_031500.txt RSK_123_20141113_081500.txt RSK_126_20141113_041500.txt RSK_126_20141113_081800.txt RSK_128_20141113_091600.txt Here, "RSK" is file prefix and 123 is a code name and rest is just timestamp of the file when its... (7 Replies)
Discussion started by: kridhick
7 Replies

10. Shell Programming and Scripting

Script needed to delete to the list of files in a directory based on last created & delete them

Hi My directory structure is as below. dir1, dir2, dir3 I have the list of files to be deleted in the below path as below. /staging/retain_for_2years/Cleanup/log $ ls -lrt total 0 drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2 drwxr-xr-x 2 root ... (2 Replies)
Discussion started by: prasadn
2 Replies
scandir(3C)						   Standard C Library Functions 					       scandir(3C)

NAME
scandir, alphasort - scan a directory SYNOPSIS
#include <sys/types.h> #include <dirent.h> int scandir(const char *dirname, struct dirent *(*namelist[]), int (*select)(const struct dirent *), int (*dcomp)(const struct dirent **, const struct dirent **)); int alphasort(const struct dirent **d1, const struct dirent **d2); DESCRIPTION
The scandir() function reads the directory dirname using readdir(3C) and builds an array of pointers to directory entries using malloc(3C). The namelist argument is a pointer to an array of structure pointers. The select argument is a pointer to a routine that is called with a pointer to a directory entry and returns a non-zero value if the directory entry is included in the array. If this pointer is NULL, then all the directory entries are included. The dcomp argument is a pointer to a routine that is passed to qsort(3C), which sorts the completed array. If this pointer is NULL, the array is not sorted. The alphasort() function can be used as the dcomp() function parameter for the scandir() function to sort the directory entries into alpha- betical order, as if by the strcoll(3C) function. Its arguments are the two directory entries to compare. RETURN VALUES
The scandir() function returns the number of entries in the array and a pointer to the array through the namelist argument. When an error is encountered, scandir() returns -1 and errno is set to indicate the error. The alphasort() function returns an integer greater than, equal to, or less than 0 if the directory entry name pointed to by d1 is greater than, equal to, or less than the directory entry name pointed to by d2 when both are interpreted as appropriate to the current locale. There is no return value reserved to indicate an error. ERRORS
The scandir() function will fail if: EOVERFLOW The number of directory entries exceeds the number that can be represented by an int. USAGE
The scandir() and alphasort() functions have transitional interfaces for 64-bit file offsets. See lf64(5). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Stable | +-----------------------------+-----------------------------+ |MT-Level |See below. | +-----------------------------+-----------------------------+ The scandir() function is Unsafe. The alphasort() function is Safe. SEE ALSO
malloc(3C), qsort(3C), readdir(3C), strcoll(3C), attributes(5), lf64(5) SunOS 5.11 4 May 2004 scandir(3C)
All times are GMT -4. The time now is 05:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy