Hello, I'm submitting this thread, because I was looking a way to delete empty directories using find and I found a thread from 2007 that helped me. I have worked from that threat, but I found that the command sent would analyze original directory and may delete it to. I have come up with expanded find command so parent directory would no be analyzed and would no put it on risk of being delete. The main problem with this command is that child directories MUST not have the same name as parent directory.
This is the initial directory setup
Now running the following Solaris command you may delete the "z" directory without putting in risk your "a" directory.
The result of the command would be like these:
Please notice that "a/z" directory is no longer present and that "a" directory was not analyzed.
You may delete "-exec echo..." from the command line and it will produce same result, that part was just to demonstrate operation of the command.
My best regard and I hope this would be of help to some one.
Every day you learn something new. I would like to write a better command with the suggestion from jpradley. thanks for you suggestion. Using xargs is good you would only need to redirect standar error to /dev/null so you would not have the error message.
So having the initial directory structure from my first post I would re-write the command as:
This will produce the same result as spected and would not analize parent directory.
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)
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)
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)
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)
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)
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)
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)
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)