I have a directory with 10000 .root
files (each looks like hists11524_blinded.root
or hists9899_blinded.root
) in it and need to run some macros for my data analysis purposes. However, I don't need all of the files (just 4000 out of all) to be in the directory. I have a list of needed runs (these 4000 numbers) in thebest.txt file
. This file is also in that directory with histograms.
I want to delete the files which are not needed for the processing before running macros by using the info from a .txt file.
That is how the thebest.txt
file looks like:
09769
09772
09773
09776
09777
09781
09782
09785
09786
09789
09790
09793
...
My guess is to work with the command:
-comm -2 -3 <(ls) <(sort thebest) | tail +2 | xargs -p rm
I get 2 errors:
tail: invalid option -- 'p'
sort: cannot read: No such file or directory
The file thebest.txt
contains only numbers with 5 digits like 09999
or 11256
, the directory contains files with names like hists9999_blinded.root
or hists11256_blinded.root
.
The number of digits in both lists are different - that is the main issue.