osx - How to archive files under certain dir that are not text files in Mac OS? -


Hey, guys, I used zip command, but I just want to store all the files except * .txt I am For example, if two diars file1, file2; Both have some * .txt files, I need only non-text archive archives from file 1 and file 2.

tl; Dr: All files that do not match * .txt

move and move to the desired directory :

  ls | Grep -P '\. (?! Txt $) '| Zip - @zipname   

This will create a zipname.zip file that contains everything but .txt files. In short, what is this:

  1. A list of all the files in the directory can be obtained by using one (this -1 option, one per line, though it
  2. Remove all the lines that do not end in .txt . Note that using Perl regular expression (option -P ) grep is used, so negative letterheads can be used.
  3. zipn in stdin ( - <@ ) Ame file.

    update

    The first method I posted failed with two files. . , As I had described in the comments. For some reason, I forgot about the -v option for grep, which only matches regex no . Also, go ahead and include case insensitive options.

      ls | Grep -vi '\ .txt $' | | zip - @zipname  < / Pre>  

Comments