I have directory "Documents" with these files:
file1.txt.
file2.txt
index.html
index.php
script.pl
I want to create zip archive named files.zip with only .txt extension files using terminal. How can I do these?
At the basic level, if you are in the same directory that your files are in, you can do :
zip files.zip *txt
And if you want to zip the files with .txt
extention, by giving the absolute path, if they are in Documents
directory, which will create files.zip
in the current directory you are in:
zip files.zip /the/path/to/Documents/*txt
If you also want this zipped file to be in Documents
folder, you should specify it as:
zip /the/path/to/Documents/files.zip /the/path/to/Documents/*txt