Sponsored Content
Top Forums Shell Programming and Scripting Deleting empty directories using find Post 302387437 by jpradley on Friday 15th of January 2010 07:13:31 PM
Old 01-15-2010
To delete empty directories under/top/level/dir using find:
Code:
find /top/level/dir/* -type d | xargs rmdir


Last edited by Scott; 01-15-2010 at 08:36 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

deleting the empty files

as of our requiremnt some x no of files will be created from a third party tool ,out of them one or two files will be empty i.e size is 0. so i want to remove those files which are empty. naming of the files which are created will be like this abc_.txt 0 size abc_1.txt 4000 size abc_2.txt... (1 Reply)
Discussion started by: srivsn
1 Replies

2. Shell Programming and Scripting

Deleting the empty file

Hi, I have a TEST.dat file. As a clean up process, I have to delete the TEST.dat file if it is empty. Basically, I don't want to delete TEST.dat if it contains anything in it but want to delete TEST.dat if it contains any spaces or nothing in it. Is there a command to check if the file... (2 Replies)
Discussion started by: rkumar28
2 Replies

3. Shell Programming and Scripting

deleting empty files in a directory

Hello Gurus, I want to delete only empty files (files with 0 bytes) at once from the local directory. Rightnow I need to go through all the files one by one manually and check the empty files before deleting them. Is there any unix command that finds and deletes empty files in a directory?... (5 Replies)
Discussion started by: berlin_germany
5 Replies

4. Shell Programming and Scripting

Deleting all empty files in sub directories with a command

Hello Friends, Im trying to delete empty files in subdirectories with a command. I can find them checking only one directory in each step and then show them with my command like below moreover i could not add removing part: ls -l */* | awk '{if ($5==0) printf "%3s %2d %s... (5 Replies)
Discussion started by: EAGL€
5 Replies

5. SCO

Deleting a directory that is not empty

I know someone will probably laugh at this question, I probably knew the answer many years ago when I was doing this full time but here goes..... I have a directory that has many files and sub-directories in it, RMDIR will not delete a directory that is not empty so what is the command to... (1 Reply)
Discussion started by: moondogi
1 Replies

6. UNIX for Dummies Questions & Answers

Deleting all rows with empty columns

I have a text file that looks like this: 1 rs523634 8.22486 1 1 rs585160 8.22488 1 rs497228 8.2249 1 1 rs600933 8.225 1 rs480106 8.22531 1 rs600199 8.22533 1 rs529015 8.22534 1 rs598894 8.22534 I want to delete the rows with empty... (2 Replies)
Discussion started by: evelibertine
2 Replies

7. Homework & Coursework Questions

Find and delete empty files and directories

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Need to make a script, to remove all empty files and folders from current category. It also should show the name... (2 Replies)
Discussion started by: Itixop
2 Replies

8. Shell Programming and Scripting

Deleting empty folders

Hey, I need help with writing a shell script that deletes empty folders..anyone? :) Thank you! (5 Replies)
Discussion started by: putukas
5 Replies

9. Shell Programming and Scripting

Find the directories and deleting with wild card

Hi Firends, I have requirement like find the directories in unix after my my deployment is done. generally my requirement as follows. /data/common/scripts is folder and it has multiple scripts in this path. I have taken the back up of scripts folder as below /data/common/0816_scripts... (4 Replies)
Discussion started by: victory
4 Replies

10. UNIX for Beginners Questions & Answers

Empty Directories

Please help me. How i can find empty directories in solaris?? (4 Replies)
Discussion started by: FoDeGe
4 Replies
pathfind(3GEN)					     String Pattern-Matching Library Functions					    pathfind(3GEN)

NAME
pathfind - search for named file in named directories SYNOPSIS
cc [ flag ... ] file ... -lgen [ library ... ] #include <libgen.h> char *pathfind(const char *path, const char *name, const char *mode); DESCRIPTION
The pathfind() function searches the directories named in path for the file name. The directories named in path are separated by colons (:). The mode argument is a string of option letters chosen from the set [rwxfbcdpugks]: +-----------------------------+-----------------------------+ | Letter | Meaning | +-----------------------------+-----------------------------+ |r |readable | +-----------------------------+-----------------------------+ |w |writable | +-----------------------------+-----------------------------+ |x |executable | +-----------------------------+-----------------------------+ |f |normal file | +-----------------------------+-----------------------------+ |b |block special | +-----------------------------+-----------------------------+ |c |character special | +-----------------------------+-----------------------------+ |d |directory | +-----------------------------+-----------------------------+ |p |FIFO (pipe) | +-----------------------------+-----------------------------+ |u |set user ID bit | +-----------------------------+-----------------------------+ |g |set group ID bit | +-----------------------------+-----------------------------+ |k |sticky bit | +-----------------------------+-----------------------------+ |s |size non-zero | +-----------------------------+-----------------------------+ Options read, write, and execute are checked relative to the real (not the effective) user ID and group ID of the current process. If name begins with a slash, it is treated as an absolute path name, and path is ignored. An empty path member is treated as the current directory. A slash (/) character is not prepended at the occurrence of the first match; rather, the unadorned name is returned. EXAMPLES
Example 1 Example of finding the ls command using the PATH environment variable. To find the ls command using the PATH environment variable: pathfind (getenv ("PATH"), "ls", "rx") RETURN VALUES
The pathfind() function returns a (char *) value containing static, thread-specific data that will be overwritten upon the next call from the same thread. If the file name with all characteristics specified by mode is found in any of the directories specified by path, then pathfind() returns a pointer to a string containing the member of path, followed by a slash character (/), followed by name. If no match is found, pathname() returns a null pointer, ((char *) 0). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
sh(1), test(1), access(2), mknod(2), stat(2), getenv(3C), attributes(5) NOTES
The string pointed to by the returned pointer is stored in an area that is reused on subsequent calls to pathfind(). The string should not be deallocated by the caller. When compiling multithreaded applications, the _REENTRANT flag must be defined on the compile line. This flag should only be used in mul- tithreadedapplications. SunOS 5.11 10 Mar 1999 pathfind(3GEN)
All times are GMT -4. The time now is 04:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy