General :: Recursive Delete Specific Files From Sub-directories?
Mar 4, 2011
I would like to be able to recursively delete specific various files from a directory and sub-directories. For example:
Dir/
|_sub1/
|
|_ _rm *file1 *file2 *file3
[code]....
View 11 Replies
ADVERTISEMENT
Jan 18, 2011
How do I recursively generate a text file which has a list of all files on my server which contain a specific string anywhere in the files?
I know the following command can be used to replace a string recursively
find /var/www -type f -print0 | xargs -0 sed -i 's/old string/new string/g'
I do not want to replace the string, I just want a list of all files which contain the string.
View 4 Replies
View Related
Jun 29, 2010
is there a recursive shell or Perl script to delete files with the same name as the parent folder? i wish to include the starting folder name as argument to the script.
View 2 Replies
View Related
Apr 7, 2011
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
./hpc06MatlabCodes/2011/Apr/3dBoxModel
./hpc06MatlabCodes/2011/Apr/3dBoxModel/vfluidIrca10.dat
./hpc06MatlabCodes/2011/Apr/3dBoxModel/vLRecoveredSystem.mat
is there a way to exclude the directories and only get the files list.
View 2 Replies
View Related
Jul 22, 2011
suppose in my current directory, I have 50 sub-directories. Now, I am interested only in about 20 of those sub-directories (whose names match a pattern). I would like to recursively list the contents of these 20 sub-directories. How do I do that ? I would like to do this in Solaris 10 and Linux(RHEL 5.x).
View 3 Replies
View Related
Jan 26, 2011
I am using CentOS 5.5 and I created few users (useradd john etc.) and now I want to assign privileges to this user on some directories and files in those directories. For example I want to give read privileges to directory "/documents" and all of files under that directory.
View 13 Replies
View Related
Aug 16, 2011
I'm looking for a Bash script that will go into a list of directories and delete all but the four most recently created files.
How can I do this?
View 4 Replies
View Related
Oct 25, 2010
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
[code]...
View 10 Replies
View Related
Mar 17, 2010
i want such a shell script or single line command to delete all the files with extension specified in script i have bash !! ex... delete all files of extension .obj
View 4 Replies
View Related
Jun 29, 2010
I'd like to create a tar file on my machine to distribute software to other machines which are all alike (including, usernames, groupnames, etc). I need to create certain files and directories with specific owners on the target machine. In order to do that, I use
Code:
tar --create --owner=someone --group=somegroup --file package.tar files. However, for this to work, someone must be in my /etc/passwd and somegroup must be in my /etc/group. Is there a way to fake this so I don't have to create a bunch of users only for that purpose?
View 3 Replies
View Related
Feb 19, 2010
I have a vary unique problem with file and directory ownership. I need to change the ownership of multiple files and directories under a specific subdirectory.Under this directory structure there are files and directories owned my different users and groups. I need to change all files and directories owned by "user1" to "user2". but if any are owned by "user3" I need those left alone.Is there a simple way to do this or will I need to traverse the structure and change things one at a time.
View 3 Replies
View Related
Jul 18, 2011
I am trying to delete specific users along with their files, these are the steps i am taking,
Quote:
sudo su -
Quote:
cat /etc/passwd
Quote:
userdel user1
userdel command not found.
I am not able to remove the specified user, Does anyone know how else to remove this user.
View 7 Replies
View Related
Aug 13, 2010
I have 50 files in the following format.
fileone.0001.txt
filetwo.0002.txt
filethree.0003.txt
[code]...
View 4 Replies
View Related
Feb 1, 2011
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?
View 3 Replies
View Related
May 21, 2011
I need a command to find the all files which filename contains the text "SomeText" and to delete that files!From /home/movie/wp-content/uploads/this folder I have lots of files and folders .Also I need that for folders and subfolders who contains some text in folder name "someTextInFolderName"
View 13 Replies
View Related
Jul 8, 2011
I ran the command:
Code:
ls -ltr | head -n40
I'd like to delete all the files listed...
View 2 Replies
View Related
Dec 19, 2009
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.
View 14 Replies
View Related
Oct 28, 2009
find out a command to search among all *.dat files in a certain path (including subdirectories) looking for the following text in them:
Code:
--------------------------------------------------------------------------------
Elements with small area
Element Adjusted nodes
--------- --------------
16294 NO
17889 NO
and getting the list of elements with small area printed in a file "ErrorEl.txt". The output should have this form:
"/path/01/A.dat
bad-el#01
bad-el#02
[code]....
I know already how to find out the dat files containg a certain string
Code:
c=/path/
grep -R --include="*.dat" "Elements with small area" $c | cut -d: -f1>> ErrorEl.txt
but I don't know then how to get the element numbers(16294 and 17889 in the example above)
View 11 Replies
View Related
Apr 4, 2011
I have a dir (pub_html) with 45 sub dirsand in each there is a file with name file123.html) what command can I use to rename all files with this name in all sub dirs to file456.html ? I'm on opensuse 11.3
View 14 Replies
View Related
Jul 29, 2010
How would I delete everything in a directory except for three specified directories?
So far I discovered I can omit the directories like so in a find search code...
View 6 Replies
View Related
Apr 16, 2010
I am writing a shell script that finds all files named <myFile> in a directory <dir> or any of its subdirectories, recursively. I also need to take care of symbolic links that may form cycles, to avoid infinite loops. I am not supposed to use find command for the same
I started writing the code but got stuck. I thought using recursion may be a smart way, but its not working.
Code:
#!/bin/sh
findFiles()
{
thisDIR=$1
#cd $thisDIR
code....
View 5 Replies
View Related
Aug 20, 2010
I have written an init script which I have kept under /etc/init.d, I need to create links to the directories rc0.d, rc1.d, rc2.d, rc3.d etc.. So that I can use chkconfig command to control the starting and stopping of the script at specific runlevels.
View 4 Replies
View Related
Jun 14, 2010
How can I delete Directories which are smaller than, say, 1000 KB?
I already have a file list from the command:
But I don't know how to proceed.
Update:
The output of:
Is something like:
View 2 Replies
View Related
Mar 23, 2011
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 !!
View 7 Replies
View Related
Jun 7, 2010
tell me the command used to find a specific word in directories and sub-directories in linux?
View 4 Replies
View Related
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.
View 8 Replies
View Related
Jul 13, 2011
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
data-20110623/
data-20110624/
data-20110625/
[code]...
View 5 Replies
View Related
Sep 16, 2009
How do i delete a specific string in vi? Suppose i want to delete only the instance "ing" occuring in a file through vi , how could i do this??
View 3 Replies
View Related
Jan 20, 2011
is there any way so that we can restrict root to delete a file/directories and What is extended file attributes.
View 12 Replies
View Related
Jul 5, 2010
My system have problem to route mail to our mail server, some mails store to mail queue, I use the command "mailq" have the below output, can advise if I want to delete a specific mail "ofdaf8fafag8sgfas", what can I do?
o639ngDV026834 515345 Mon Jul 5 17:49 <mail1@ora-test.com>
(Deferred: Connection refused by ora-route)
ofdaf8fafag8sgfas 514345 Mon Jul 5 17:49 <mail2@ora-test.com>
(Deferred: Connection refused by ora-route)
Total requests: 36
View 5 Replies
View Related