Find a file

see attachment. I need to find a FOLDERS using just the first word of the folder (ie SUV28). So I need to find the SUV28 folder in "Features1/SU"

Here is something I have trying to get to work but can't. Can anyone help me make this work.

This is actually in Applescript on Mac.

set proj_code to "SUV28"
set basePosix to quoted form of (POSIX path of "Features1:SCRIPTS:SU:" & proj_code & " *")
set the_SCRIPT_folder to (do shell script "ls -d " & basePosix)
set x to the_SCRIPT_folder

Dropbox - SUV28.png

This should find anything starting with what you want, but finds everything, not just folders:

find / -name 'SUV28*'

but you may have to pipe the output thru

grep "^dr"

to only get directories.

HTH

Hopefully this example will shed some light to usage in your example
This is on debian, but it should work anywhere.

user@hostname:~Features1/SU$ pwd
/home/user/Features1/SU
user@hostname:~Features1/SU$ ls -lrt
total 12
drwxr-xr-x 2 user group 4096 Jun  1 04:57 'SUV25 Johnson, Ben'
drwxr-xr-x 2 user group 4096 Jun  1 04:59 'SUV563 Oort, Jan'
drwxr-xr-x 2 user group 4096 Jun  1 05:00 'SUV28 Curie, Marie and Pierre'
drwxr-xr-x 2 user group 4096 Jun  1 05:10 'SUV286 Baggins, Frodo'

# we only find directories SUV28 in above output, but any regular expression will do
user@hostname:~/posao/struk$ find /home/user/Features1/SU -type d -name "SUV28\ *" -exec ls -dl {} \; 
drwxr-xr-x 2 user group 4096 Jun  1 05:00 '/home/user/Features1/SU/SUV28 Curie, Marie and Pierre'

Hope that helps
Regards
Peasant.

That does not work.
But you can filter for directories in find

find / -type d -name 'SUV28*'
1 Like

if I use this:

find / -type d -name 'SUV28*

how does it know what folder to look in to ie "Features1/SU"
how do I tell find to look into the Features1/SU folder for the SUV28 folder.

find will search the entire directory tree under the given start directory and descend into each and every subdir unless told otherwise.