Sponsored Content
Full Discussion: Delete files in a txt file
Top Forums UNIX for Dummies Questions & Answers Delete files in a txt file Post 302968284 by Don Cragun on Monday 7th of March 2016 01:56:18 PM
Old 03-07-2016
Unless you have a list of files (as assumed in the code RavinderSingh13 suggested), you could try something like:
Code:
find /dir1 /dir2 ... /dirN -type f ! -newer trigger_path -exec echo rm {} +

where /dir1 ... /dirN are pathnames to the roots of the file hierarchies you want to process and trigger_path is the pathname of a file (not located in any of the file hierarchies you want to process) that has a timestamp indicating the oldest file you want to keep. (You can create such a file using the touch command using a -t option to specify the boundary date and time.) If the pathnames printed by this looks right, take out the echo to actually remove the files.

Note that if you use this with any file hierarchies containing files that are part of your system's initial installation, this can turn your system into a doorstop that will no longer run and won't boot. Don't try this if you don't know what you're doing. There is a huge difference between very old and not needed!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Command to delete numbers at beginning of txt file line

Hello. I have the following issue: my txt file has the following format: train/dr4/fklc0/sx175.txt 0 80282 Severe myopia contributed to Ron's inferiority complex. train/dr4/fklc0/sx355.txt 0 42906 Dolphins are intelligent marine mammals. train/dr4/fklc0/sa2.txt awk 'NR%2==0' test1.txt >... (4 Replies)
Discussion started by: li_bi
4 Replies

2. Shell Programming and Scripting

Script to delete all something.txt~ file from a directory

There are some files in a directory like a.tx~ , b.txt~,c.txt~. I want to delete all these files inside that directory and sub directory. How can i do this? #!/bin/bash cd thatdirectory ...... rm -rf *~ ...... (7 Replies)
Discussion started by: cola
7 Replies

3. UNIX for Dummies Questions & Answers

recursive delete files from txt file or?

i have a txt file of image names that have to be deleted in pwd how can i use the txt file to delete the files in pwd and is it possible?--i might be able to import the txt files into a spreadsheet ahd same it as a csv file. i want it to be done recursive lly --what i mean is teh sysem goes thru... (4 Replies)
Discussion started by: plener
4 Replies

4. Shell Programming and Scripting

script to delete lines from a txt file if pattern matches

File 6 dbnawldb010-b office Memphis_Corp_SQL_Diff Memphis-Corp-SQL-Inc-Application-Backup 03/09/11 03:24:04 42 luigi-b IPNRemitDB Memphis_Corp_SQL_Diff Memphis-Corp-SQL-Inc-Application-Backup 03/10/11 00:41:36 6 ebs-sqldev1-b IPNTracking Memphis_Corp_SQL_Diff... (4 Replies)
Discussion started by: ajiwww
4 Replies

5. Shell Programming and Scripting

Delete file2.txt from file1.txt using scripting

Hi, I`m a total newbie, well my requirement is that i have 2 files I want to identify which countries i do not currently have in db.. how can i use the grep or another command to find this file .. i want to match all-countries.txt with countries-in-db.txt so the output is equal to... (11 Replies)
Discussion started by: beanbaby
11 Replies

6. UNIX for Dummies Questions & Answers

Delete files whose file names are listed in a .txt file

hi, I need a help. I used this command to list all the log files which are for more than 10 days to a text file. find /usr/script_test -type f -mtime +10>>/usr/ftprm.txt I want all these files listed in the ftprm.txt to be ftp in another machine and then rm the files. Anyone can help me... (8 Replies)
Discussion started by: kamaldev
8 Replies

7. Shell Programming and Scripting

Delete specific parts in a .txt file

Hi all, I desperately need a small script which deletes everything in a particular .txt file when "Abs = {" appears till "},", and also when "B-1 = {" appears till "}," I would like all the text in between of those instances to be deleted, however, other text to be unedited (kept as it is).... (12 Replies)
Discussion started by: c_lady
12 Replies

8. Shell Programming and Scripting

Compare two txt files,mismatches will be in new txt files

Hi, Below are the sample data for txt files. txt file 1 Partnumber|catgroup_id 10001082|46016 10001093|4680 10001093|386003 10001093|463004 10003251|683 10003251|63005 10003252|463005 10003252|4683 10003260|463005 10003260|4683 10003264|4683 10003264|463005 13420000|67... (5 Replies)
Discussion started by: Ankita Talukdar
5 Replies

9. UNIX for Dummies Questions & Answers

Delete .txt file from current directory

I have created few text file during run time by redirecting the txt file echo USER_LIST_"$(date '+%d%h%Y')".csv > report_location.txt report_location.txt is creating in the same location where I run script home/script When I try to remove the txt file at the end of the... (3 Replies)
Discussion started by: stew
3 Replies

10. UNIX for Dummies Questions & Answers

Script to delete files line by line in .txt document

Friends, I am in need to delete files from a directory on a regular basis. I want to place all the files to be deleted in delete .txt file and require a script to delete files, line by line from this delete.txt file. Please help me with this script as am new to unix scripting. (3 Replies)
Discussion started by: fop4658
3 Replies
CLOUDSERVERS(1) 						   User Commands						   CLOUDSERVERS(1)

NAME
cloudservers - Command-line interface to the Cloud Servers API. SYNOPSIS
cloudservers [ --username USERNAME ] [ --apikey APIKEY ] <subcommand> DESCRIPTION
cloudservers is a command line interface to the Rackspace Cloud Servers API. COMMAND OVERVIEW
cloudservers backup-schedule Show or edit the backup schedule for a server. cloudservers backup-schedule-delete Delete the backup schedule for a server. cloudservers boot Boot a new server. cloudservers delete Immediately shut down and delete a server. cloudservers flavor-list Print a list of available 'flavors' (sizes of servers). cloudservers help Display help about this program or one of its subcommands. cloudservers image-create Create a new image by taking a snapshot of a running server. cloudservers image-delete Delete an image. cloudservers image-list Print a list of available images to boot from. cloudservers ip-share Share an IP address from the given IP group onto a server. cloudservers ip-unshare Stop sharing an given address with a server. cloudservers ipgroup-create Create a new IP group. cloudservers ipgroup-delete Delete an IP group. cloudservers ipgroup-list Show IP groups. cloudservers ipgroup-show Show details about a particular IP group. cloudservers list List active servers. cloudservers reboot Reboot a server. cloudservers rebuild Shutdown, re-image, and re-boot a server. cloudservers rename Rename a server. cloudservers resize Resize a server. cloudservers resize-confirm Confirm a previous resize. cloudservers resize-revert Revert a previous resize (and return to the previous VM). cloudservers root-password Change the root password for a server. cloudservers show Show details about the given server. Optional arguments: --username USERNAME Defaults to env[CLOUD_SERVERS_USERNAME]. --apikey APIKEY Defaults to env[CLOUD_SERVERS_API_KEY]. See "cloudservers help COMMAND" for help on a specific command. cloudservers March 2010 CLOUDSERVERS(1)
All times are GMT -4. The time now is 11:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy