I've got a directory that looks like
$ ls
Broad_hapmap3_r2_Affy6_cels_excluded.tgz DINGO.tgz GIGAS.tgz index.html IONIC.tgz passing_cels_sample_map.txt SCALE.tgz
CHEAP.tgz EPODE.tgz HOMOS.tgz index.html?C=M;O=A LOVED.tgz PICUL.tgz SHELF.tgz
CORER.tgz excluded_cels_md5.txt HUFFS.tgz index.html?C=N;O=D NIGHS.tgz POSIT.tgz SLOTH.tgz
CUPID.tgz excluded_cels_sample_map.txt HUSKS.tgz index.html?C=S;O=A passing_cels_md5.txt SAKES.tgz TESLA.tgz
I want to unzip all the files that match the extension *.tgz with a single command, except Broad_hapmap3_r2_Affy6_cels_excluded.tgz.
I can do
ls *.tgz | xargs -n1 tar zxvf
for all the *tgz files, but what's a good way to exclude a subset of them? From reading online maybe find is indicated in this situation, but it seems like overkill. Thank in advance.
Addendum: I'd also be interested in alternative methods to the question without excluding files.
Best Answer
You could always do:
But I suspect somone will post a cleaner way do do this directly from the bash shell without needing a grep in there.