Finding DIR

Done this basic level script called mydir that prints the message File is a directory if
the file is a directory.

Code:

#!/bin/kasha
 
cat LIST | while read LINE
do
  if [[ $? -eq 0 ]]
  then
    ls -ltr $LINE >out
    give=$LINE
    grep $1 out > out.txt
    grep ^d out.txt
    if [[ $? -eq 0 ]]
    then
      echo "Directory "$give
    if
  if
done
LIST file Contains Directory path
/dir/man
/dir/con
/dir/sam

If you have any better way to find plz post...

Please, can you clarify? You have a list of directories. You want a script that receive a name as argument. If exists in one of directories in list a directory with the name in paremeter echoes a message.
Is this what you want?

Yes Franzpizzo ...you are correct

The script is working. But we need to specify the directory names in the LIST(file)..

If i want to search from root ?

You can get rid of the useless cat:

while read ...
do
...
done < inputfile

Ok Corona..But i need to specify the directory names in the LIST(file) to search..

Instead, i want to search the directory from root "/" to all the child tables. Post if any

What do you mean by 'all the child tables'?

for DIR in /*
do
        [ -d "$DIR" ] || continue

        echo "$DIR is a dir"
done

I mean Child Directorys....

Ya the above script will check each and every file from /*.

But im passing the directory name as a argument and checking weather it is a File or a directory.
LIKE:
./file directoryname

How this should be done ?

if ! [ -d "$1" ]
then
        echo "$1 is not a directory"
        exit 1
fi