find -type d returning files as well as directories


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users find -type d returning files as well as directories
# 1  
Old 03-04-2010
find -type d returning files as well as directories

Can anyone see why the following command returns all files and not just the directories as specified?

find . -type d -exec ls -F {} \;

Also tried
find . -type d -name "*" -exec ls -F {} \;
find . -type d -name "*" -exec ls -F '{}' \; -print

Always returns all files :-\

OS is SUSEv10.
Thanks,
Mike.
# 2  
Old 03-04-2010
your find looks for directories that exec ls -F display content (so files...)
# 3  
Old 03-04-2010
So I should have used -d with the ls :

find . -type d -exec ls -dF {} \;

to make the ls just display the dir and not the contents.

Thanks,
Mike.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find common files between two directories

I have two directories Dir 1 /home/sid/release1 Dir 2 /home/sid/release2 I want to find the common files between the two directories Dir 1 files /home/sid/release1>ls -lrt total 16 -rw-r--r-- 1 sid cool 0 Jun 19 12:53 File123 -rw-r--r-- 1 sid cool 0 Jun 19 12:53... (5 Replies)
Discussion started by: sidnow
5 Replies

2. UNIX for Advanced & Expert Users

Find all files in the current directory excluding hidden files and directories

Find all files in the current directory only excluding hidden directories and files. For the below command, though it's not deleting hidden files.. it is traversing through the hidden directories and listing normal which should be avoided. `find . \( ! -name ".*" -prune \) -mtime +${n_days}... (7 Replies)
Discussion started by: ksailesh1
7 Replies

3. Programming

C++ Returning enumerated type

I am trying to create a function to return me the verbosity level, so I can call it as follows String s = "normal"; Verbosity log_level; log_level = get_log_level(s); I started a version in the last function but I am having trouble getting it to work. #ifndef __VERBOSE_HH__... (1 Reply)
Discussion started by: kristinu
1 Replies

4. Shell Programming and Scripting

Find Files with a input in directories

So i have directories that store logs, 1 directorie for each day, with the name like this : 2012_07_01/ 2012_07_02/ and for each directorie we have the logs, inside them lives the logs for that day, and every log have this name pattern : ... (2 Replies)
Discussion started by: drd0spt
2 Replies

5. Shell Programming and Scripting

find command to filter specific type of files older than certain date.

Hi I need to find the list of files in a directory and to do some specific operations based on the type of files. suppose in a directory am having .dat , .log, .err, .rej file types. i need to filter out .dat and .log only which are older than six months. i used the below query but the... (2 Replies)
Discussion started by: msathees
2 Replies

6. Shell Programming and Scripting

Deleting all files recursively from directories while ignoring one file type

Hi, Seems like I need help again with a problem: I want to delete all files from my lets say "Music" Directory inkluding all of the subfolders except for .mp3 and .MP3 files. I tried it with globalignoring mp3 files, finding and deleting all other files, which resulted in all files... (3 Replies)
Discussion started by: pasc
3 Replies

7. Shell Programming and Scripting

Find files of type within folder copy multiple results to different folders

Ok question number two: I'd like to search a directory for multiple file types (rar, txt, deb) and depending on what's found, copy those files to folders named Rar, TextFiles, and Debs. I'm looking for speed here so the faster the script the better. I want it to be a function that I pass 1 argument... (4 Replies)
Discussion started by: DC Slick
4 Replies

8. Shell Programming and Scripting

Find problem listing directories even -type f

Hi All, #!/bin/ksh find /home/other -ls -type f -xdev | sort -nrk7 | head -2 >bigfile.txt The above is my script, which writes the large file into a file called bigfile.txt. My script contains only the above two lines. after execution i am getting the output like find: cannot chdir to... (1 Reply)
Discussion started by: Arunprasad
1 Replies

9. UNIX for Advanced & Expert Users

User friendly Unix ksh prompt to type directories/files

Hello, I wanted to setup user friendly ksh command prompt, by typing first character of files or directories and then tab bring up whole word. No need to type whole file/directory/command names. Example: cat a file like university just typing un and then tab bring up whole university wod.... (3 Replies)
Discussion started by: abdurrouf
3 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