I use find to find the directory, but I don't know how to print it first and then output it.

write a shell script that looks at the contents of the current directory and prints out the word "Directory" for all directories, followed by a comma-separated list of directory names and contents sorted by modification time, and all files print the words "file" and file name
clipboard.png

.
Nov.11,2021

looks like an assignment.

anyway

there are many kinds of shell scripts, such as a version of bash for reference

-sharp!/bin/bash
walk() {
        local indent="${2:-0}"
        for entry in "$1"/*; do
                [[ -f "$entry" ]] && printf ": %*s%s\n" $indent '' "$entry"
                [[ -d "$entry" ]] && printf "Direcotry: %*s $entry \n" $indent &&   walk "$entry" $((indent+4))
        done
}
walk "$1"

give another idea

-sharp!/bin/sh

for filename in ./*
do
if [ -d "$filename" ]; then

  echo "Directory: $filename /n `ls -l -t` $filename /n"

else [ -f "$filename" ]; 

  echo "file:$filename"

fi
done
Menu