LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Bash script to delete folder's that are listed in a text file (https://www.linuxquestions.org/questions/programming-9/bash-script-to-delete-folders-that-are-listed-in-a-text-file-697273/)

Bone11409 01-14-2009 10:44 AM

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.

repo 01-14-2009 10:54 AM

what have you done already?

Bone11409 01-14-2009 11:30 AM

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

jcookeman 01-14-2009 11:48 AM

Why dont you give us an example of the file you need to read from?

pixellany 01-14-2009 11:53 AM

Quote:

Originally Posted by Bone11409 (Post 3408505)
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.

Bone11409 01-14-2009 12:10 PM

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

Disillusionist 01-14-2009 02:58 PM

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.

pixellany 01-14-2009 05:43 PM

Quote:

Originally Posted by Disillusionist (Post 3408718)
Please post what you have tried (preferably in [CODE] tags).

As a minimum, get comfortable with the use of the "read" command, and post that portion.....

Bone11409 01-14-2009 08:36 PM

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.

pixellany 01-14-2009 09:24 PM

I am concerned that you don't seem to want to read a book, online tutorial, etc.--or even try the commands that I suggested.

Please tell us where you are in the class---specifically, we need to know what commands and techniques you have already studied.

If it helps, what you are trying to do is quite simple. Many of us could write the script in the same time it would take to find something similar.

Bone11409 01-15-2009 07:43 AM

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.

repo 01-15-2009 07:56 AM

Quote:

when you don't know what I have done.
Show us what you have so far

pixellany 01-15-2009 07:58 AM

Bone;

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.

Bone11409 01-15-2009 08:22 AM

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

pixellany 01-15-2009 08:25 AM

We tried.....

reported for closure


All times are GMT -5. The time now is 12:24 PM.