[Shell Script] How can I do this recursive search in a directory?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
But unfortunately I only get the files in that directory and I need recursive search.
The final output must be this:
The classification of the files in the diretory XXXX is:
- There is/are X file/s with the extension/pdf: X1, X2... Xt
- There is/are Y file/s with the extension/jpeg: X1, X2... Xv
etc.
you've been given answers --- more input here besides what you just wrote... savy?
Id like to have a method that make a recursively list with the files and their types, using Find and File (and surely while) commands.
Then, one that show only types, calling to the last one to have a list of types and use cut and sort to take types and remove duplicates.
After that one that show files of a particular type that receives as a parameter. It will use the first method, grep, cut and sort, combining the last two procedures (along with other commands as while and wc).
Id like to have a method that make a recursively list with the files and their types, using Find and File (and surely while) commands.
Then, one that show only types, calling to the last one to have a list of types and use cut and sort to take types and remove duplicates.
After that one that show files of a particular type that receives as a parameter. It will use the first method, grep, cut and sort, combining the last two procedures (along with other commands as while and wc).
Sorry for my English, I'm from Spain.
R U Taking Bash Scripting in School? Es esta tarea ???
to help you with your english:
Quote:
I'd like to have a method that creates a recursive list with the files and their types, using Find and File (and surely using a while loop ) commands.
Then, one that shows only file types, calling to the last one <-- what does the word one represent, the last file, or function call?
to have a list of types and use cut and sort to take the file types and remove duplicates. or can be said or written as such, and remove duplicate files. : for clarity.
but still that last statment calls for a question:
to remove duplicate files from the list or to remove the duplicate files off the hard drive themselves?
After that one (one being what?) that show files of a particular type that receives as <- remove a parameter.
After that process, then have it show files of a particular type that receives a parameter telling it to show only the matching type.
then you'd have to explain how is it going to receive this parameter. off the command line, or within the script itself. is it to be written to give the user a list to pick from, or does the user have to go into the script and modify it first himself? before going into this part of it,
It will use the first method, grep, cut and sort, combining the last two procedures (along with other commands as while and wc).
this last statment projects to may variables in what it is that actually needs to be done. furthermore, is this to be written all within one script?
is it to be put into functions then called from that, one after the other, or witten in a Procedural programming style?
I'm at the university, and no, this is not my tarea xD.
I'm studying for an exam, and teachers recommended us some exercises about bash scripts, not mandatory to do. I just want to have the highest mark.
Thank you anyway
another quicker way is to google it section by section in what it is you are wanting to remember so you can impress your teacher and hopefully get a better grade, but if you do not actully learn the how to's then it is still just a waste for your time, and mine. because for me to even try and figure it all out for you, one I have no use of this information, and two it will be very time consuming for me to do for you. maybe others know a quick way to do all of this in a short manner.
I'd try your luck googling how to's and reading up on the answers other give others in the other fourms all over the world and kept in this internet.
because if you are taking any kind of programming course it is all the same only the syntex is different. even with OOP
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.