1) find /path/sol ----> would list all files in /path/sol
2) grep .so --> would list all files that end with .so
3) grep 3 --> would list all files (path) that contains "3"
My understanding is that you wish to identify any file, anyname.so, that is in a directory named sol, so that the important part of the pathname is sol/anyname.so. There may be other .so files in other directories, but you do not wish to identify those.
If that is so, then here is a script that creates a small tree, including sol and sol/sol and creates files t(n).so in those directories. It then uses the regular expression feature in find to identify the paths which contain the string of interest. In particular there are .so files in directories not named sol, which should not be listed:
#!/bin/sh
# @(#) s1 Demonstrate regular expressions in find.
echo " sh version: $BASH_VERSION"
# Destroy and re-create directory structure.
DIRS="a sol sol/b sol/b/sol sol/sol"
rm -rf $DIRS
mkdir $DIRS
i=1
for d in $DIRS
do
touch $d/t${i}.so
(( i += 1))
done
echo
echo " Small tree showing files *.so in directories."
tree .
echo
echo " Results from find using regular expression predicate regex:"
find . -regex '.*/sol/[^/]*so'
exit 0
Producing:
% ./s1
sh version: 2.05b.0(1)-release
Small tree showing files *.so in directories.
.
a
/ t1.so
readme.txt
s1
sol
/ b
/ / sol
/ / / t4.so
/ / t3.so
/ sol
/ / t5.so
/ t2.so
Results from find using regular expression predicate regex:
./sol/b/sol/t4.so
./sol/sol/t5.so
./sol/t2.so