Bash script to delete folder's that are listed in a text file
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
Bash script to delete folder's that are listed in a text file
I have been trying to find a bash scrpit that will delete folders that are listed in a text file. The text file is generated once a month and list only the folder's name in a column view. If anyone could help me I would sure appreciate it.
no I have look on the forums for a script that is simailar to what I need to do but have had no lucky finding one I am hopeing someone could point me to a script that I could look at and go from there so far I have been able to look at someone else's script and been able to change it to what I need with some help from the forum's and google
no I have look on the forums for a script that is simailar to what I need to do but have had no lucky finding one I am hopeing someone could point me to a script that I could look at and go from there so far I have been able to look at someone else's script and been able to change it to what I need with some help from the forum's and google
Please break up the run-on sentences.
The way this reads (to me) is that you first say you have not been able to find anything, and then you say:
Quote:
I have been able to look at someone else's script and been able to change it to what I need with some help from the forum's and google
Also, please confirm if this is homework.
Here is a hint to get started
use the "read" command to read one line at a time into a variable (eg dirname), then use "rmdir $dirname".
Use the redirection operator (<) to cause "read" to read from a file and not STDIN.
What I have is a text file that has in it a list of folder names that need to be deleted. What I would like to do is have a script look at the text file and delete folders based upon the information in the text file. And what I meant to say is that I have been able to firugre out what I need to do for my other script but not this one mainly cause I am stuck. Sorry if I confused anyone
Please post what you have tried (preferably in [CODE] tags).
pixellany has offered some advice on where to begin but you must understand that this smells of homework to us, and whilst we may offer pointers and suggestions, we are not here to do your homework for you.
This is not intended to cause you problems, it is just that if we give you the answers with out you understanding the issue, we are not helping you in the long term.
There are a number of bash tutorials that may prove useful.
I understand what you mean by homework but I did not ask you to write a script for me I ask if you could point me to scripts similar to what I am doing.
I have already spend two week's looking on forums and watching online tutorial's just to get to this point and it seem that you do nothing but critsize me for not reading books and watching tutorial's when you don't know what I have done.
No one here has anything to gain by criticizing you---I for one had no such intent.
The issue we are having is that people ask you questions to try and assess where you are in the learning process, and we are not getting clear answers.
So, here are a few specific questions which would help us to help you:
1. Where are you in the class? For example, have you studied all of the basic Bash commands--also called the core utilities?
2. Have you used the "read" command? To read from standard input--ie the keyboard? To read from a file?
2A. As part of this, have you used the redirection operators? ("<" and ">")
3. Have you used the "rmdir" command?
4. Are you familiar with basic loops--eg "for", "while"?
5. Are you familiar with assigning a variable (name = <something>) and then retrieving the value with "$name"
Here's another huge hint: The above is pretty much all you need for your script.
Thanks for all the help you gave me but I am going quit trying to do this in linux and do this in windows mainly cause I am use to it and that I can get some help from my friends so once again Thanks
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.