Remove the 'echo' once you've tested and are sure it really does what you want.
I have run the below command but i need to print to a file where it shows what files have been deleted?
sudo xargs rm <file
Btw all the files are in directory under "/" . But the input file is something like below (i.e) it dont have any path to the file. So i need a command which deletes these files without storing the input file inside the directory under / where the original files reside.
more file
0012301170
0000013300
0000014100
-
-
-
Thanks for the quick reply.
---------- Post updated at 02:18 PM ---------- Previous update was at 02:13 PM ----------
Corona,
Can you please suggest whether i can use the below script to delete the files?
If yes i want an echo statement to be printed on what files have been deleted and what file are not found in the directory?
P.S: I need to delete close to 100K files and the file anmes are listed in the input file.
Thanks
---------- Post updated at 04:10 PM ---------- Previous update was at 02:18 PM ----------
Could you please help me in deleting the large set of files without moving the input file to a directory where original files reside.
Thanks
Last edited by Franklin52; 08-21-2012 at 05:27 AM..
Reason: Please use code tags
for i in `cat file`; This will be especially bad for what you want because it will try -- and fail -- to cram all 100,000 filenames into one thing and die with 'too many arguments'.
If your rm has the -v (verbose) option you could do this, assumption is your file_list.txt and logs are in the /tmp directory.
Thanks for the post. so if use the below script it is giving me illegal option --v errors, so i have taken -v option and have run the command it worked fine. But is there a way to capture all the files which were deleted in this operation?
I can see the data for which files were not found from errors.list
Well any file in the original filelist that isn't in the error list was removed.
Can you output the first few lines of the error file ( head /tmp/errors.list ) file so we can see the format, a simple awk script should be able to produce the removed files list.
Hello, my first thread here.
I've been searching and fiddling around for about a week and I cannot find a solution.:confused:
I have been converting all of my home videos to HEVC and sometimes the files end up smaller and sometimes they don't. I am currently comparing all the video files... (5 Replies)
Hi GUys
I have a script where i am counting the number of files that the user has read permissions to in a folder . They are asked for this folder at the start
if they dont enter anything then i want to be able to do the search on the current directory, can you help me with that part please... (25 Replies)
Hi
My directory structure is as below.
dir1, dir2, dir3
I have the list of files to be deleted in the below path as below.
/staging/retain_for_2years/Cleanup/log $ ls -lrt
total 0
drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2
drwxr-xr-x 2 root ... (2 Replies)
I will simplify the explaination a bit, I need to parse through a 87m file -
I have a single text file in the form of :
<NAME>house........
SOMETEXT
SOMETEXT
SOMETEXT
.
.
.
.
</script>
MORETEXT
MORETEXT
.
.
. (6 Replies)
Help needed urgently please.
I have a large file - a few hundred thousand lines.
Sample
CP START ACCOUNT
1234556
name 1
CP END ACCOUNT
CP START ACCOUNT
2224444
name 1
CP END ACCOUNT
CP START ACCOUNT
333344444
name 1
CP END ACCOUNT
I need to split this file each time "CP START... (7 Replies)
Hello,
I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall:
I regularly need to delete files from many directories.
A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
I need to write a shell script for below scenario
My input file has data in format:
qwerty0101TWE 12345 01022005 01022005 datainala alanfernanded 26
qwerty0101mXZ 12349 01022005 06022008 datainalb johngalilo 28
qwerty0101TWE 12342 01022005 07022009 datainalc hitalbert 43
qwerty0101CFG 12345... (19 Replies)
I have a file <filestodelete> containing names of files to to be deleted from a directory <filesstore>.
I want a script file which accptes the <filestodelete> and also the location of the directory(<filestore>) and deletes all files matching.
Thanks in Advance.. (3 Replies)
hi
i am having four files in a directory.like
1)sampleRej
2)exampleRej
3)samplemain
4)examplemain
my requirement is i have to search for the rejected files (sampleRej,exampleRej) in a directory.if these files in that directory then i have to delete the main files... (3 Replies)