Programming :: List Specific Files And Delete Results?
Jul 8, 2011I ran the command:
Code:
ls -ltr | head -n40
I'd like to delete all the files listed...
I ran the command:
Code:
ls -ltr | head -n40
I'd like to delete all the files listed...
I have 50 files in the following format.
fileone.0001.txt
filetwo.0002.txt
filethree.0003.txt
[code]...
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 RelatedI need to search a bunch of files in a specific folder for a specific number and add all the numbers together to a total sum. I use Rsync everyday, everytime I run rsync i get a logfile (rsync output) witch contains the textstring "Total bytes sent: xxxxxx".
The "xxxxx" can vary in lenght. I need to extract the "xxxxxx" from each file and add the numbers together to a total size over a week or a month. Is this possible? And I wish to only use bash. One way of doing stuff at a time my friends .
These must a be a question you received a lot, but I couldn't find a similar thread! It's a simple question.
I need to delete a specific string from a file. For example the specific numbers "3456" from a file. I've tried with the tr comand, using
Code:
tr -d '3456' file,
but it also deleted whichever ocurrence of 3,4,5,6 from my file. Should I use a regular expression?
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.
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]....
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 RelatedI 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.
I want a list of all my mp3 files (or any other kind of file, actually) telling me HOW MANY OF THEM I have in my computer.I tried with both find and locate commands in terminal, but they don't tell me how many files I have.
View 2 Replies View RelatedI 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?
View 3 Replies View RelatedI am trying to get this script to work. The purpose is to download a list of modules from the slax.org the list consist of a list of module numbers. What I am trying to do is Download the file or the file name corresponding to the number in the list.the list is comma delimited. this is what I have done so far and I am a stand still.
#!/bin/sh
# Wget script to retrieve modules from slax.org modules
#
# ----Begin of user defined values -----
# Path to wget
[code].....
Im reading in file /proc/cpuinfo into a char array.Im using strstr to search for a string im interested in (the cpu speed line) and storing it in another char array.I want to just store the line that contains CPU speed but im getting everything after the CPU speed line in the char array too.Is there anything better than strstr or is there someway i can parse the the payload data (i.e. the actual cpu speed)
View 4 Replies View RelatedI want to delete all files within a specific folder without actually deleting the folder, what is a good bash command for this?. I found this one but encountered some errors even though I am executing it within the specific folder:
useratdebian:/home/user/folder# find . -type f -exec rm -rf {} ;
[1] 5052
useratdebian:/home/user/folder# find: missing argument to `-exec'
[1]+ Exit 1 find . -type f -exec rm -rf
The command as it appears is:
find . -type f -exec rm -rf {} ;
how to delete only the files contained within the folder called "folder" for example?
I have a script that checks a folder for zip files than moves them to a different folder. I want to check every 5 maybe 10 seconds and since cron is setup to run at least a 1 minute increment I'm not sure how to do that time check as probably a loop within the script. One other thing is once the time check is in the script how would a cron job be setup to run this script? Once the script is running cron doesn't need to run it again, is there a feature to check if it's running and if it's not then run it?
find /export/xxxshare -name "*.zip" -exec mv {} /export/store ;
I am new to unix, I am looking for a script to delete files older than 7 days but i also want to exclude certain directories (like arch,log .....) and also some files with extensions ike .ksh, .ch, ..............) in directories and sub directories
View 4 Replies View RelatedWe have a problem at work that we are using Word Press And now for security we have to delete install.php in WP-Admin and rename upgrade.php and install_helper.php to *.bak
Im a noob in Script creating (Had a bit practice a couple of years ago but allready forgot T.T) So what i ask that is there a way to make a script
That:Finds wp-admin(if it exists) folder enters into it and there deletes install.php and renames upgrade.php and install_helper.php to *.bak and the makes the same process again untill theres no wp-admin folders left with these files, We have alot of web pages so manually it would take about a month to find em all (about 3000 pages :
I am writing a script to delete certain files
say
Code:
find / -name lighttpd
gives following output
Code:
/etc/init.d/lighttpd
/etc/lighttpd
/home/lighttpd
/opt/lighttpd-1.4.x/src/lighttpd
I do not want to delete file in home directory but rest all. In one shell script. So first line I am clear with but what can be the second line,
I am an uploader to a various hosts, so this tiny script me a lot. I make a rar archive and split files with 100mb. I could get 3-4 or even 76 parts of rar files and it would take me some time to paste all these urls to remote upload function of filehosting sites. For example:
Code:
server:/home/cober/downloads/teevee# ls -al
total 358784
drwxrwxrwx 2 root root 4096 Dec 8 19:38 .
[code]....
the moment the file name goes as backup-"$(date +%d-%b-%y)" so something like backup-13-Feb-11.I have already setup in my script to make sure the backup was successful and is not corrupt what I need to do next if for exampleif I backup for 21st feburarybackup-21-Feb-11if it finds anything older than five days for examplebackup-13-Feb-11 it will delete this. I want the old delete part to work on the filename not a system time stamp
View 7 Replies View RelatedI have to display from the list of files given as parameters the name of the file with the largest number of words and their number.(with AWK)
View 2 Replies View RelatedIs there a way, preferably in python or BASH, to rename files from a list? for instance, track1.mp3, track2.mp3 should be renamed to the names stored in a file listing song names. I have tried to loop a variable through directory listing and renamed them, only to find that filenames with spaces can't be assigned to a variable as a whole. To solve the problem above, I have tried the read command in BASH, which enables the program reading line by line from a list. However, It was failed to pipe the results from directory listing to the read command.
View 14 Replies View RelatedI have made a shell script to copy and delete files through FTP.I want to first delete all txt files and then mput all txt files.
Code:
ftp ()
{
[code]....
I am facing a problem in Windows due to a virus called Newfolder.exe which creats files with the same name as it's parent directory and an extension .exe and this happens for every directory in the entire hierarchy in the infected pen drive. The antivirus detects them, but is sucking slow. So I thought this is a good opportunity to use the concepts of the all mighty shell script to remove those as they follow the same pattern. Say my complete path is
Code:
/home/pkd/fol1/
The virus would have created an file with complete paths
Quote:
/home/pkd/fol1.exe
If fol1 has two more directories fol11 and fol12 Then there would be two more .exe(virus created) in the following path
Quote:
/home/pkd/fol11/fol11.exe
/home/pkd/fol12/fol12.exe
I have 2 external hdd in wich I have all my files. yesterday, I have copied all the files from hdd2 to hdd1 and I want to eliminate duplicates so I used FSLint to find them,now I want to make a shell script to delete all the files/entries (read from the log file) that begin with.
View 14 Replies View RelatedI have a shell script that need to create some files:
1) backup files of user passed in file ( that will be written by this shell ).
2) temp files that the shell will create and later delete/remove.
This shell script will be used from my local dir ( I am not a super or a sysadmin ). Users of this shell will call this script to run on their local files in their respective directories. When my script runs, it errors with the following:
cp: cannot create regular file `./listfile.txt.backup': Permission denied
/home/myUser/tools/myShellScript: line 12: listfile.txt: Permission denied
for the temp I was able to avoid this error by creating the temp file in the /tmp directory. All I want is for this shell script to run, create/modify/backup files in user's local dirs.
The user dir has the following permission:
drwxr-xr-x testDir
the file that needs to be backed-up has:
-rw-r--r-- listfile.txt.
How to list only hidden files in current directory ?
View 2 Replies View RelatedHow to list all the files that don't contain pattern1 and append a new line (pattern1) to those files before pattern2 only once.
pattern1 = /var/script/showMessage.sh
pattern2 = ;;
Code:
grep -c 'pattern1' /var/script/*_cam* | grep :0 | add pattern1 before pattern2 in each file loacted before.
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'm trying to do a
find /photos/* -type f -mtime +365
to find all my pictures that are over a year old, but I keep getting argument list too long. How can I view what all the results are, even if it just dumps it to a file that I have to open?