Answer the question
In order to leave comments, you need to log in
How to archive with the zip command in Linux?
How to implement such a thing from the console.
For example, I have three files in my folder:
file1.txt
file2.txt
file3.txt
You just need to create their archives next to them with the names saved, like:
file1.txt
file1.zip
file2.txt
file2.zip
file3.txt
file3. zip
I'm dumb
Answer the question
In order to leave comments, you need to log in
If just like in the example, then here:
If otherwise. Then you need to tweak the command. The meaning of a team is this.
ls runs through the directory and pipes everything it finds with a .txt extension to the program's sed editor. Sed truncates extensions using regular expressions to leave filenames for later use.
All this business in the loop leads to the fact that what is executed in the $ () command at the beginning of the line (these are the origins of the shell) is substituted into the $ i variable. And a string is formed for execution.
Here it turns out like this:
zip -9 1.zip 1.txt
zip -9 2.zip 2.txt
....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question