find directories


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting find directories
# 1  
Old 03-18-2009
find directories

I am looking a script which will find garbase directories (10 char. long)..which need to delete empty dir excluding symlink and system directories.
I tried this partial script but it just find directories create a file which contains link directories..can somebody help me to complete this scripts.

!#/usr/bin/sh

for dir in $(find / -type d -name '??????????')
do ll $dir | grep ^l > /home/user/linklist
if [ ls $dir eq 0 ] then rmdir $dir # not sure abt this line
done
# 2  
Old 03-19-2009
Define "system directories". Also, doing a find of "/" will take a very long time and you may not have permissions depending on your access.

You may wait to use
Code:
-fstype ext3

to avoid any problems.
# 3  
Old 03-19-2009
find directories

HI have super access , i want to exclude directories they have link jusyt want to delete empty directories with 10 charactor long
# 4  
Old 03-19-2009
Be very careful when you run this.

First identify what the directories are:
Code:
find / -name "??????????" -type d -empty -ls

Then delete (be careful, I am warning you)
Code:
find / -name "??????????" -type d -empty -exec rmdir {} \;

# 5  
Old 03-19-2009
getting error..

find / -name '??????????' -type d -empty -ls
find: 0652-017 -empty is not a valid option.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Ubuntu

Find duplicates among 2 directories

I have 2 directories, /media/andy/MAXTOR_SDB1/Ubuntu_Mate_18.04/ /media/andy/MAXTOR_SDB1/Linux_Files/. I want to find which files are duplicates so I can delete them from one of those directories. (13 Replies)
Discussion started by: drew77
13 Replies

2. Shell Programming and Scripting

Find and Copy Directories ONLY

I am trying to copy only the date specific folders/directories using the following command. However, the following copy command is also copying files from the root folder (OriginalFolder). find /OriginalFolder/ -type -d \{ -mtime 1 -o -mtime 2 \ } -exec cp -R {} /CopyTo/'hostname'__CopyTo/ \;... (2 Replies)
Discussion started by: apacheLinux
2 Replies

3. UNIX for Advanced & Expert Users

How to find particular word in directories?

Hello, i have multiple directories on my server. i need to find specific word like lets says for e.g IPV6 from those directories. can somebody tell me the right command which will let me to that? (8 Replies)
Discussion started by: Jared
8 Replies

4. Shell Programming and Scripting

Excluding directories from a find

I've looked at a few similar threads, but I can't bridge from those examples to what I'm working on, so I'm hoping someone can help. I want to extend the following statement find $PathToCheck -type f \( -not -iwholename "$ScriptDir/*" \) -exec md5sum "{}" \;>$NewSigs to exclude several... (9 Replies)
Discussion started by: nixie
9 Replies

5. 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

6. Shell Programming and Scripting

Find directories by regex

Hello, I want to check if directories exist with a regex expression dir1=/temp/local/*/home (exists on file system) dir2=/temp/server/*/logs (does not exist on file system) I want to check if there are any directories with the above regex Code: if ];then echo "Directory... (4 Replies)
Discussion started by: gogineni
4 Replies

7. Shell Programming and Scripting

to find the size of directories

Hi, how to know the size of the files in the directory, exclusing the subfolder. ? i tried du -h du -sk du -k but its not giving.. (2 Replies)
Discussion started by: mail2sant
2 Replies

8. Shell Programming and Scripting

How to find 777 permisson is there or not for Directories and sub-directories

Hi All, I am Oracle Apps Tech guy, I have a requirement to find 777 permission is there or not for all Folders and Sub-folders Under APPL_TOP (Folder/directory) with below conditions i) the directory names should start with xx..... (like xxau,xxcfi,xxcca...etc) and exclude the directory... (11 Replies)
Discussion started by: gagan4599
11 Replies

9. Shell Programming and Scripting

Find Directories That Do Not Contain A Certain File

I'm having problems figuring out the process to find directories that DO NOT contain a certain file. I have a mp3 collection that all the album art is name "folder.jpg". Not all the albums have images. I need a way to find the albums/directories that do not contain "folder.jpg". I can find the... (2 Replies)
Discussion started by: subsonic
2 Replies

10. Shell Programming and Scripting

Find files in Directories

Hello, We have in a file a list of the path of files from one server. We want to search if these files exist on another server , but the path on this new server isn't the same. We want to use the command "awk" but there isn't the god way. Example: on server 1 in a file : listServer1.txt... (4 Replies)
Discussion started by: steiner
4 Replies
Login or Register to Ask a Question