LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-14-2009, 10:44 AM   #1
Bone11409
LQ Newbie
 
Registered: Jan 2009
Posts: 19

Rep: Reputation: 0
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.
 
Old 01-14-2009, 10:54 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
what have you done already?
 
Old 01-14-2009, 11:30 AM   #3
Bone11409
LQ Newbie
 
Registered: Jan 2009
Posts: 19

Original Poster
Rep: Reputation: 0
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

Last edited by Bone11409; 01-14-2009 at 11:32 AM.
 
Old 01-14-2009, 11:48 AM   #4
jcookeman
Member
 
Registered: Jul 2003
Location: London, UK
Distribution: FreeBSD, OpenSuse, Ubuntu, RHEL
Posts: 417

Rep: Reputation: 33
Why dont you give us an example of the file you need to read from?
 
Old 01-14-2009, 11:53 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by Bone11409 View Post
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.
 
Old 01-14-2009, 12:10 PM   #6
Bone11409
LQ Newbie
 
Registered: Jan 2009
Posts: 19

Original Poster
Rep: Reputation: 0
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
 
Old 01-14-2009, 02:58 PM   #7
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
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.
 
Old 01-14-2009, 05:43 PM   #8
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by Disillusionist View Post
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.....
 
Old 01-14-2009, 08:36 PM   #9
Bone11409
LQ Newbie
 
Registered: Jan 2009
Posts: 19

Original Poster
Rep: Reputation: 0
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.
 
Old 01-14-2009, 09:24 PM   #10
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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.
 
Old 01-15-2009, 07:43 AM   #11
Bone11409
LQ Newbie
 
Registered: Jan 2009
Posts: 19

Original Poster
Rep: Reputation: 0
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.
 
Old 01-15-2009, 07:56 AM   #12
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Quote:
when you don't know what I have done.
Show us what you have so far
 
Old 01-15-2009, 07:58 AM   #13
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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.
 
Old 01-15-2009, 08:22 AM   #14
Bone11409
LQ Newbie
 
Registered: Jan 2009
Posts: 19

Original Poster
Rep: Reputation: 0
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
 
Old 01-15-2009, 08:25 AM   #15
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
We tried.....

reported for closure
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script- text file manip- delete everything before/after string justin99 Programming 9 11-20-2014 03:16 AM
Need a bash shell script which will delete lines from file scjohnie Linux - Newbie 1 09-13-2008 08:51 PM
bash script to create text in a file or replace value of text if already exists knightto Linux - Newbie 5 09-10-2008 11:13 PM
A script within a folder to delete the folder, script, and the folder's contents Cyberman Programming 15 10-17-2007 07:32 AM
How to delete a line from a text file with shell script programming Bassam General 1 01-28-2004 08:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration