Hey im completely new to bash scripting and have no idea how to search the directory name then print out the path where it was found, the filename is entered thru the command line like "./search.sh pictures" and then would make the script print all directory path names which contain the word "pictures" and print them out in order of closest to furthest but only going as deep as 5 directories, and printing an error if no directories are found with that name, is this possible?

I’ve been reading intro tutorials and searching google but haven’t found a way to do this, any help would be very appreciated

You could look into using find: find / -name $1 or you could try doing it by piping it to grep: find / | grep "$1" , but in order for you to make it go from shallowest to deepest, you might have to do something with sort, such as piping the data to it: find / | grep "$1" | sort -g . As for only going 5 levels deep, and printing errors if not found, you are probably bound to rely on awk and/or sed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.