Skip to main content
added exclude .files option
Source Link

My solution is toSolution using only use the find command'find':

find /tmp -type d -exec find {} -depth -maxdepth 1 -type f -print -quit \; 

This will print the first filename, including path, for every directory in /tmp.

 find /tmp -type d -exec find {} -depth -maxdepth 1 -type f ! -name '.*' -print -quit \; 

This will print the first filename in every directory, but skip over DOT files.

Works both on Linux and Mac.

My solution is to only use the find command:

find /tmp -type d -exec find {} -depth -maxdepth 1 -type f -print -quit \; 

This will print the first filename, including path, for every directory in /tmp

Solution using only 'find':

find /tmp -type d -exec find {} -depth -maxdepth 1 -type f -print -quit \; 

This will print the first filename, including path, for every directory in /tmp.

 find /tmp -type d -exec find {} -depth -maxdepth 1 -type f ! -name '.*' -print -quit \; 

This will print the first filename in every directory, but skip over DOT files.

Works both on Linux and Mac.

Source Link

My solution is to only use the find command:

find /tmp -type d -exec find {} -depth -maxdepth 1 -type f -print -quit \; 

This will print the first filename, including path, for every directory in /tmp