General :: Script To Delete A List Of Directories?
Oct 24, 2010
how to write a short script file to read file (text) contains a list of directories name and delete everything in it. There are 10,000 directories - So there is NO WAY I can do manually.
I have generated a list of directories that I would like to use ls and grep on, but it is not working. I am using the commandCode:cat directories.dat | xargs lsand I get a whole lot of these errors:Code:ls: cannot access ./foo/bar/baz/grault/*: No such file or directorybut when I try the directories manually one at a time I find that they all exist and all have files in them. Same thing if I try to grep anything. What is going wrong?
I have tried to find the solution for my problem on this site and other sites but haven't found a good enough answer yet. Maybe some of you can help me out here?What i need is a script (bash preferrably) that can delete directories based on a date in its dirname.For example.I have a bunch of directories that is named
I am trying to write a script to pick the directory name from a list of file. Here is a detailed picture.Have a file name LIST which contains the follwing for example/apps/oracle/product/test1/apps/oracle/product/test2/apps/oracle/product/test3I need a script that reads these line from LIST and creates foldersin /apps/oracle/product/test1/backup/date/test1 after reading the first line /backup/date/test2 after readin the second line/backup/date/test3 and so on.
i've been wondering how do i know if some users create/modify/delete file/directory in linux, i've been using pyinotify in python script.this script like the example from the manual:
Code: #!/usr/bin/python import pyinotify, os, time
I'm looking for a way to produce a list of all the directories in the current working directory sorted by the total number of files that are contained with them.
Initially I though that Nautilus could be used for this, but then I realised it doesn't count files in the sub directories.
The best I've got for a command line solution so far is this
Code:
The use case for this is a situation where a user has a quota applied to their home directory which limits the number of files they are allowed to have and they have exceeded that limit.
I am trying to write a simple back up script in python where I try to list the files that are 24 hours old in specific directories that I would choose.I read the manual of find and used
find . -mtime 1 > log.dat
to get the list of files in the log.dat however I also get the path information in that list as such
I want to know how much damage a user can do on my system if he decides to delete everything (or write to in case of corruption).What command or script might i use to check this?
How can only directories be listed, that do not have another child directory?
Imagine a structure like /A /A/AA /A/AB /A/AB/ABB /B /C /C/CC /C/CC/CCC /C/CC/CCC/CCCC I would like to use find to list only /A/AA /A/AB/ABB /B /C/CC/CCC/CCCC.
The starting point would be find . -type d, but neither -mindepth nor -maxdepth can be used, can -noleaf help (I could not get it to react the way I wanted it to)?
I discovered two folders marked with a cross in my root:
- root - lost+found
And when I'm trying to reinstall a newer version of Netbeans, 6.9.1. it claims that there is already something running in 'root folder "The installer lock file exists at /root/.nbifile/.nbillock"
The question is - is those folders are needed for Ubuntu working? -If not how to delete them? And one more question - how to delete a programme from the 'Applcations-Programming'? I tried to do that via 'System-Preferencies-Main Menu' and tried to delete a previous version of Netbeans, but it didn't work, - nothing happens, the previous version is still there, so I have two ones - 6.9.1 and 6.9.
I have a large music directory that I'd like to somehow acquire, or generate, a list of each sub-folder within it, and then somehow get the list into a spreadsheet format. Is there a way to do this?
I recently used up all my free inodes on my server. I had a bunch of mail messages that were sitting there using up a bunch, so I cleared the postfix queue. That gave me some room. What I'd like to do, is get a listing of the directories using the most inodes (or containing the most number of files), so that I can find the other culprits.Basically I want the output of "df -i" but to be able to do it recursively on a specific directory.
I need a command to list the total sizes for all the directories in a mounted drive.I tried df and du.df list the total size for the mounted drivedu depending on what option I give it either list the total size or list all the sizes for every file on the drive.All I want to know is the sizes of all the directories on the mounted drive.This is a windows vista hard-drive and for some reason ubuntu is reporting a 50 GB partition and only 10GB free, I want to know what's taking up all the free space. I can't find anything in the file browser, so far I've only managed to count up about 10GB of used space so where is the other 30GB.
I have two users in home on Debian stable: user1 and ftpuser.Proftpd is configured so that it uses ftpuser for clients.How to set it up so that user1 can modify, delete, etc.. all files and directories that ftpuser creates?
I need to, through a bash script, go through a given directory (given as argument 1) to list out the relative path in this directory (including $1) for eact subdirectory which contains files. Directories which only contain . .. and eventually only subdirectories SHALL NOT be listed. It is this last requirement that makes it difficult for me.
I have been using the tree command for now, but I have not found a way to ignore paths to directories which only contains other subdirs or nothing at all in any easy way. I may offcourse test each directory after they are listed but this gives an extra loop to go through and I beleive it should be possible to do it directly when creatring the list. I guess by using find or ls in conjuntion with the tree command or by itself it should be possible but I am not to conversant of nested script commands.
i am in need of linux help. iam at college and i need this back/restore script to pass this final part of an assessment. i require a backup script that will not only backup but also restore files to the relevent directories. e.g. users are instructed to store all wordprocessor files in a directory named wp. so i am needing to create a backup directory and 3 directories within that and some files within the 3 directories and then back them up ot restore them. l know i should/have to do this myself by been trying to get/understand info for the last few days and came up with zero.
I want to make a webserver with multiple users allowed to login through SFTP to a specific folder, www.Multiple users are added, lets say user1 and user2, and all of them belonging to the www-data group. The www directory has an owner www-data and a group www-data.
I have used chmod -R 775 on the www folder, but after I try to create a folder test through my SFTP server (using Filezilla) the group of the directory created has only r and x permissions, and I am not able to log in with the second user user2 and create a directory within www/test due to a lack of w permission to the group.
I also tried using chmod 2775 on www directory, but without luck. Can somebody explain to me, how can I make it so that a newly created directory inherits the root directory group permissions?
I am writing a script, in that my requirement is, if all the fill types stored in one directory from that we need to separate different different directories based on the file types.
for example in a directory(anish). 5 different types files 1- directory 2- .txt files 2- .sh files
like that and my requirement is the (1- directory is moved to one new directory(dir) which we are given in the script)and (2 .txt files are moved to another new directory(test) which we are given in the script)and ( 2 .sh files are moved to another new directory(bash) which we are given in the scrip)finally the directory anish should be empty..using bash script.how it is possible !!
how to change (rename, delete) lines from boot list in grub 2, Ubuntu 10.04? For example, when I boot my pc, I have a boot list with options "Ubuntu 10.04", "memtest" and "Windows 7". I want to delete "memtest" line, as I don't need it, and rename "Windows 7" line to, for example, "Windows 117". How can I do that? Where I should look and edit? In old grub it was enough to edit /boot/grub/menu.lst, but in Ubuntu 10.04 there is no such file and other grub2-related files (like grub.cfg) do not contain this info to rename or delete lines. So, I can't figure out what to do.