Recursivity
Hello,
I need a script which lists all files in directories (recursively). The root dir will be passed as argument. I want to compile this script with command: cc <script_filename.c> -o <filename> Have anyone experience with that? I appreciate all your answers! |
Well you don't compile scripts, first of all. What you are talking about it writing something in C/C++.
If you want a recursive listing of files, you can already do that on the command line without writing a program to do it. Or are you just trying to do this for your own knowledge? |
Homework perhaps?
|
ou, yes, of course it is not script :rolleyes: i'm sorry.
Yes, it is a part of my school project, but I want to know something about that. I can read C/C++ code, but I am newbie in Linux :study: and then I dont know how to do that. Google found something but it compiled with errors... :mad: Thanks for your replies ;) |
Can't help you with the C part of it, but try typing the following at a command line:
du and also man du |
It would do you a dis-service to just give you code to solve your homework problem. However thank you for being clear that it is homework. I am happy to point you in the right direction.
The function calls you need to know about to get directory listings are:
Code:
man 3 opendir To build a C program, you can use the gcc program (this stands for GNU C Compiler). C++ programs are built using g++. Assuming your program code is all in one file called myprog.c, the command to compile and link is simply: Code:
gcc -g myprog.c -o myprog |
Many many THANKS matthewg42,
I am glad of your answer and wish you the best in the future! Once again, Thank you :) |
No problem. If you have any further questions please ask. People here (me included) are reluctant to post solutions to homework questions, but so long as the questioner shows that they have tried something and ask about specific points, they will get lots of answers.
So if you have problem with a specific build error, or maybe some segment of the code does something inexplicable, post what you have done (code in [code] tags to aide readability), and you will probably get lots of helpful answers :) |
All times are GMT -5. The time now is 10:33 PM. |