I am still not getting nowhere with this.
I have tried this as well
xxxx]$ cd /home/mandri/Desktop/test
test]$ zip -e >/home/mandri/Desktop/test.zip
That accepts the password,and creates a zip archive on my desktop.
The terminal just stalls at the line adding: — and the zip archive remains at 0 bytes.
I also tried this
cd Desktop
Desktop]$ zip -e test >test
bash: test: Is a directory
For recursive subdirectories I guess you’ll need to pipe the output of find into the input of zip. But I’ve not tried this.
So I then tried this
Desktop]$ zip -e test >test.zip
Enter password:
Verify password:
zip warning: missing end signature—probably not a zip file (did you
zip warning: remember to use binary mode when you transferred it?)
zip error: Zip file structure invalid (test.zip)
I also tried this
Desktop]$ zip -e test >test/*
bash: test/*: ambiguous redirect
Then this
Desktop]$ zip -e test/* >test.zip
Enter password:
Verify password:
This seemed to finish,and it created a zip archive on my desktop,and I didn’t see it stall at adding: — like earlier.
But the zip archive is still 0 bytes.There’s nothing in it.
I should add because you gave examples of .txt,I am trying to zip an entire directory(a folder containing a few other folders)one folder with wallpapers,another folder with pictures from my camera,and also including text files within the parent directory,which is /home/mandri/Desktop/test
And oh yeah,I’m getting so caught up in this,I almost forgot to say thanks for replying.
So THANKS.
EDIT
Desktop]$ zip -e test/* >test.zip
Enter password:
Verify password:
This seemed to finish,and it created a zip archive on my desktop,and I didn’t see it stall at adding: — like earlier.
But the zip archive is still 0 bytes.There’s nothing in it.
I seen there was a file size of 118 bytes,not near enough for the wallpapers and .jpegs.
When I try to open it,I get the error «Could not open the file, probably due to an unsupported file format».
Using ark,I get «an error occured when trying to open the archive».
I have since tried this too,no luck.
cd Desktop
Desktop]$ zip -e -r test >test2.zip
Enter password:
Verify password:
zip error: Nothing to do! (test.zip)
Desktop]$ zip -e -R test >test2.zip
Enter password:
Verify password:
zip error: Nothing to do! (test.zip)
Desktop]$
Edited February 14, 2008 by mandri
Hi All,
I’m trying to zip a large file, approx. 57 GB. But, I’d also like to split it into individual, zipped pieces. So far, I have not been successful. Could someone help out with the correct command?
Let’s call this file ‘dummy.txt’ (it is a text file) for the purposes of this discussion.
I tried:
zip — s 2g dummy.zip dummy.txt
zip error: Invalid command arguments (cannot write zip file to terminal)
Manual pages show -s as being a valid option.
s splitsize
—split-size splitsize
Enable creating a split archive and set the split size.
A split archive is an archive that could be split over
many files. As the archive is created, if the size of
the archive reaches the specified split size, that
split is closed and the next split opened. In general
all splits but the last will be the split size and the
last will be whatever is left. If the entire archive
is smaller than the split size a single-file archive is
created.
Split archives are stored in numbered files. For exam-
ple, if the output archive is named archive and three
splits are required, the resulting archive will be in
the three files archive.z01, archive.z02, and
archive.zip. Do not change the numbering of these
files or the archive will not be readable as these are
used to determine the order the splits are read.
Split size is a number optionally followed by a multi-
plier. Currently the number must be an integer. The
multiplier can currently be one of k (kilobytes), m
(megabytes), g (gigabytes), or t (terabytes). As 64k
is the minimum split size, numbers without multipliers
default to megabytes. For example, to create a split
archive called foo with the contents of the bar direc-
tory with splits of 670 MB that might be useful for
burning on CDs, the command:
zip -s 670m -r foo bar
could be used.
Currently the old splits of a split archive are not
excluded from a new archive, but they can be specifi-
cally excluded. If possible, keep the input and output
archives out of the path being zipped when creating
split archives.
Using -s without -sp as above creates all the splits
where foo is being written, in this case the current
directory. This split mode updates the splits as the
archive is being created, requiring all splits to
remain writable, but creates split archives that are
readable by any unzip that supports split archives.
See -sp below for enabling split pause mode which
allows splits to be written directly to removable
media.
The option -sv can be used to enable verbose splitting
and provide details of how the splitting is being done.
The -sb option can be used to ring the bell when zip
pauses for the next split destination.
Split archives cannot be updated, but see the -O
(—out) option for how a split archive can be updated
as it is copied to a new archive. A split archive can
also be converted into a single-file archive using a
split size of 0 or negating the -s option:
split size of 0 or negating the -s option:
zip -s 0 split.zip —out single.zip
I’m indifferent to how it is done, and have seen that maybe I need to use a combination of split and zip commands??
OS:
Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC
Copyright (c) 1983, 2013, Oracle and/or its affiliates. All rights reserved.
Assembled 17 January 2013
Regards,
Charles
I need to compress 80.000 files into multiple zip files. This is the command I use:
zip -s 200M photos_test/*
However I get the following error:
-bash: /usr/bin/zip: Argument list too long
What can I do to solve the issue, beside manually splitting the folder files ?
thanks
shgnInc
4257 silver badges17 bronze badges
asked Apr 19, 2011 at 8:49
1
If you want the whole directory, you could simply use the -r
switch:
zip -r -s 200M myzip photos_test
That will include all subdirectories of photos_test
though.
answered Apr 19, 2011 at 9:00
MatMat
7,8931 gold badge32 silver badges32 bronze badges
2
The problem seems to be the expansion of the «*». Use folder name or «.»:
If you want to include the root folder within the zip:
zip -r my.zip folder_with_80k_files
If you don´t want to include the root folder inside the zip:
cd folder_with_80k_files
zip -r my.zip .
answered Oct 18, 2014 at 10:29
stoffenstoffen
2512 silver badges4 bronze badges
find photos_test/ -mindepth 1 -maxdepth 1 | zip -@ -s 200M
answered Apr 19, 2011 at 9:03
3
ls photos_test | zip -s 200M -@ photos
-@
will cause zip to read a list of files from stdin|
will pipe an output ofls
into the input ofzip
command
man zip
:
USE ⋮ -@ file lists. If a file list is specified as -@ [Not on MacOS], zip takes the list of input files from standard input instead of from the command line. For example, zip -@ foo will store the files listed one per line on stdin in foo.zip. Under Unix, this option can be used to powerful effect in conjunction with the find (1) command. For example, to archive all the C source files in the current directory and its subdirectories: find . -name "*.[ch]" -print | zip source -@ (note that the pattern must be quoted to keep the shell from expanding it). ⋮
answered Jul 11, 2017 at 8:14
Mr. TaoMr. Tao
4361 gold badge4 silver badges13 bronze badges
Содержание
- Исправлено: невозможно развернуть Zip файл на Mac —
- Причины, по которым невозможно развернуть Zip файл?
- Способ 1: распаковать файл с помощью терминала
- Способ 2: использование утилиты для декомпрессии
- Ejr mac os terminal zip error invalid command arguments cannot repeat names in zip file
- Thread: create zip files in ubuntu command line
- create zip files in ubuntu command line
- Re: create zip files in ubuntu command line
- Re: create zip files in ubuntu command line
- Ошибка zip: недопустимые аргументы команды (невозможно записать файл zip в terminal)
- 1 ответ
- Похожие вопросы:
- Fix Terminal “Operation not permitted” Error in macOS Big Sur, Catalina, Mojave
- How to Fix “Operation not permitted” Error in Terminal for Mac OS
- Related
- Enjoy this tip? Subscribe to our newsletter!
- Thank you!
- Related articles:
- 58 Comments
Исправлено: невозможно развернуть Zip файл на Mac —
ZIP — это формат файла архива, который поддерживает сжатие данных без потерь. Этот файл, как и другие форматы архивных файлов, представляет собой просто набор из одного или нескольких файлов и / или папок, но сжимается в один файл для удобной транспортировки и сжатия. Тем не менее, некоторые пользователи Mac OS получают сообщение об ошибке, когда они дважды щелкают по zip-файлу, чтобы распаковать его. Они получают сообщение об ошибке «Невозможно раскрыть filename.zip (Ошибка 1 — Операция не разрешена.) » и это отображается в диалоге Archive Utility.
Невозможно раскрыть ошибку на Mac
Причины, по которым невозможно развернуть Zip файл?
Мы исследовали эту конкретную проблему, изучив различные пользовательские отчеты и стратегии исправления, которые обычно использовались для устранения неполадок и устранения проблемы пользователями, оказавшимися в аналогичной ситуации. Основываясь на наших исследованиях, существует несколько различных сценариев, которые, как известно, вызывают это конкретное сообщение об ошибке:
Если вы активно ищете способы устранения этого точного сообщения об ошибке, которое мешает вам использовать zip-файлы, то эта статья предоставит вам список качественных шагов по устранению неполадок. Ниже вы найдете коллекцию методов, которые другие затронутые пользователи успешно использовали для решения этой конкретной проблемы.
Способ 1: распаковать файл с помощью терминала
Когда простой двойной щелчок по zip не работает, вы всегда можете попробовать разархивировать файлы в Терминале. Иногда файлы большого размера не могут быть распакованы в Archive Utility, и его необходимо распаковать в Terminal. Для распаковки zip-файлов в Терминале используется простая команда «unzip». При использовании этой команды файл перейдет в папку учетной записи пользователя. Чтобы разархивировать файл в Терминале, выполните следующие действия:
(Вы можете перетащить zip-файл, чтобы он тоже мог вставить каталог)
Использование команды cd для изменения каталога, а затем разархивировать в терминале
Если это не решит проблему для вас, не беспокойтесь, попробуйте следующий метод ниже.
Способ 2: использование утилиты для декомпрессии
Теперь иногда могут возникнуть проблемы с вашими разрешениями или открытием zip-файла в обычном режиме. Но в App Store и в Интернете существует множество программ Utility, которые помогут вам без проблем распаковать zip-файлы. Вы можете скачать Stuffit Expander из Mac App Store и попробуйте использовать это для zip-файла. Большинство пользователей не смогли разархивировать файлы даже с помощью терминала, но использование этого программного обеспечения помогло им решить проблему. Вы можете проверить шаги ниже, чтобы разархивировать с помощью этого приложения:
Источник
Ejr mac os terminal zip error invalid command arguments cannot repeat names in zip file
Does anyone know a good terminal command to get this done quickly and efficiently?
By my calculations this will reduce the file size by half, and would greatly help me. I won’t individually zip them if there’s no easy way to do it, it’s not worth 400mb of extra space for an afternoon’s work.
you could try something like
I’m getting an error when I run this command.
zip error: Invalid command arguments (cannot write zip file to terminal)
Am I lacking something in my install, or inputting the command incorrectly?
Just searched for my error on Google, and found this page (http://zotline.com/shownote.zot/NoteNum/4419.html), where it says that I have to «give the name of the zipfile you want to create on your command line.». Any way to have the zip program generate names based off of the file’s names?
your best bet may be to write a shell script to do it using foreach and basename to generate new filenames, and pass those to zip
Thanks a lot for the idea of using a bash script, but unfortunately yours doesn’t seem to work.
When I run it inside the directory, I get a lot of these sorts of errors:
zip error: Nothing to do! (Duel.zip)
zip warning: name not matched: Stories
zip error: Nothing to do! (Stories.zip)
zip warning: name not matched: (U).gbc
zip error: Nothing to do! ((U).zip)
zip warning: name not matched: Zebco
zip error: Nothing to do! (Zebco.zip)
zip warning: name not matched: Fishing!
zip error: Nothing to do! (Fishing!.zip)
zip warning: name not matched: (U).gbc
zip error: Nothing to do! ((U).zip)
zip warning: name not matched: Zoboomafoo
zip error: Nothing to do! (Zoboomafoo.zip)
zip error: Invalid command arguments (short option ‘.’ not supported)
zip warning: name not matched: Playtime
zip error: Nothing to do! (Playtime.zip)
zip warning: name not matched: in
zip error: Nothing to do! (in.zip)
zip warning: name not matched: Zobooland
zip error: Nothing to do! (Zobooland.zip)
zip warning: name not matched: (U).gbc
I don’t really know enough about bash to know what the problem is, but I’ve been looking around trying to learn how it all works.
Источник
Thread: create zip files in ubuntu command line
Thread Tools
Display
create zip files in ubuntu command line
i want to zip a entire folder of files. So i entered the following command
But zip gives me a error.
Re: create zip files in ubuntu command line
Have a look at man zip for more info
Re: create zip files in ubuntu command line
Note that *.* is the DOS way of globbing. To pick all (non-hidden) files in a directory in Linux, use * instead. You also use the wrong argument order for the zip command. The name of the zip file comes first, the stuff you want in the file comes second. That’s why you got the weird error.
Now if you wanted to zip the directory into one compressed file, follow mutley89‘s advice. But if you are trying to compress each file into a self-named zip file, then that’s not what you want, and I think just correcting your syntax will not help. I say that because you seem to be imagining that both wildcards in your command will be expanded to the same filename, resulting in a series of commands like zip file1.zip file1, zip file2.zip file2, and so on, with n commands for n files in the directory. But I don’t think that is what will happen.
When I want to do a «for each» kind of operation, I use a short script, which can be entered at the command line. For you, something like this will work if your (reordered) original command doesn’t work.
Источник
Ошибка zip: недопустимые аргументы команды (невозможно записать файл zip в terminal)
Я изучаю книгу укус Python. После ввода примера в книге
Я иду сообщение zip error: Invalid command arguments (cannot write zip file to terminal) я не могу понять, где идет не так, я набираю тот же код в этой книге. Кто-нибудь знает, почему это происходит?
1 ответ
Я извлекаю zip файлов с помощью 7zip в SSIS. Проблема в том, что источник может содержать недопустимые файлы zip. Есть ли способ поймать недопустимые файлы zip в SSIS, чтобы он пропустил файл и обработал следующий?
Было бы легче увидеть ошибку таким образом.
Похожие вопросы:
Это было предложение из другого потока стека, к которому я наконец возвращаюсь. Это было частью дискуссии о том, как встроить инструменты в файл maya. Вы можете записать все это как пакет python.
Я пытаюсь записать файл zip, используя wxZipOutputStream. Код взят с этого форума и работает с файлом xml (когда я использовал wxTextOutputStream). Теперь я пытаюсь включить файл изображения, но.
Я извлекаю zip файлов с помощью 7zip в SSIS. Проблема в том, что источник может содержать недопустимые файлы zip. Есть ли способ поймать недопустимые файлы zip в SSIS, чтобы он пропустил файл и.
Я создал файл zip (sample.zip), в котором есть некоторые файлы без каких-либо проблем. Когда я открываю sample.zip, он содержит ожидаемый файл. Я хочу поместить этот файл zip в ответ http. В.
У меня есть следующая проблема: Я использую 7-Zip в своем пакете SSIS 2012. Так что я создал задачи выполнение процесса и поставить там: WorkingDirectory : C:Program Files7-Zip (это правильно.
Я пишу сценарий bash, основанный на zenity, который позволяет пользователю выбирать файлы для сжатия и сжимать их с помощью zip. Проблема в том, что всякий раз, когда я добираюсь до части zipping.
Источник
Fix Terminal “Operation not permitted” Error in macOS Big Sur, Catalina, Mojave
If you’re a Mac command line user you may have noticed that many frequently used commands entered into the Terminal (or iTerm) result in an “Operation not permitted” error message since updating to MacOS Mojave 10.14 or later. The “Operation not permitted” error in the Terminal can be seen after issuing even simple commands like using ‘ls’ ‘mv’ and ‘cp’ within the users own directory, but also in many other directory locations on the Mac, and when trying to use many defaults commands. Obviously this type of error message makes navigating and using the command line in MacOS Mojave to be quite difficult if not impossible for many purposes. Don’t worry, the Terminal is not broken in new MacOS versions.
This walkthrough will show you how to fix “Operation not permitted” error messages seen at the command line in Terminal for Mac OS in Mojave 10.14 or later.
How to Fix “Operation not permitted” Error in Terminal for Mac OS
If you have not encountered the “Operation not permitted” error message in the Terminal of MacOS (Mojave 10.14 or later) yet, then it’s likely because you haven’t wandered into a directory or file path that has the additional access restrictions (or that you don’t use Terminal, in which case this entire article is not for you).
While many of the various core System and root directories will throw error messages in macOS Terminal too, you can also find the error message even when trying to work in the users own Home directory, including in many of the user
/Library/ folders, like
/Library/Messages (where iMessage attachments and chat logs are stored in Mac OS) and
/Library/Mail/ (where user-level mail plugins, mailbox data, and other Mail app data is stored), and many others.
You can test this yourself, before and after making the settings adjustment outlined above with a simple command like using ls on one of the protected folders:
If Terminal does not have Full Disk Access granted, you will see the “Operation not permitted” error message.
If Terminal does have Full Disk Access granted, or if SIP is disabled, you will not see that error message in the MacOS Terminal.
In case you were wondering, yes that does mean there are actually two ways to fix the “Operation not permitted” errors you may encounter in MacOS Terminal; the first which we detail here is rather simple that grants additional access privileges to Terminal app, and the other is a bit more dramatic which involves disabling System Integrity Protection on the Mac which is generally not recommended and we won’t specifically cover here, though simply disabling SIP and rebooting is typically enough to make the error go away if you’d rather go that route.
The “Operation not permitted” message is one of a variety of command line errors you may encounter in Mac OS Terminal. Another frequently seen command line error is the the “command not found” error message which can also be encountered in the Terminal for MacOS for a variety of different reasons as well.
If you have any other tips, tricks, suggestions, or thoughts about the command line in MacOS or this particular error message, share with us in the comments below.
Enjoy this tip? Subscribe to our newsletter!
Get more of our great Apple tips, tricks, and important news delivered to your inbox with the OSXDaily newsletter.
Thank you!
You have successfully joined our subscriber list.
Related articles:
I found that virtual box running ubuntu could do stuff sroot on terminial on macos could not WTF.
But that does mean I have a separate spot to go whenever there is a problem without having to open terminal up for ALL users ( IE me when am just mis-typing)
This works like charm!
Thank you
A million thanks worked perfectly.
work like a charm, thanks for safe my days
Thanks, hint about how to give Terminal full disk access saved my day
Remember when Apple’s slogan was “it just works”? That was nice.
thx a lot
I had to give permission to the terminal in order to use a dd command to clone a HDD drive
that’s really helpful, thanks very much!
This fixed my problem under macOS 11.2.2. Until now, I never encountered such a problem. Thanks.
Still impossible to issue rm commands
Thank you so much. Helped fix my error related to XCode not recognizing my modules and not being able to open one of the files associated to the modules. Much thanks!
Just fixed this problem for the following scenario in Catalina. I have a backup script that runs from /etc/daily.local and therefore needs full disk access. The /etc/.local scripts are run by “periodic”, so you’d think dragging /usr/sbin/periodic to “Full Disk Access” under System Preferences > Security & Privacy would work. No, it turns out that “periodic” is run by /usr/libexec/periodic-wrapper and that’s the program that has to be given Full Disk Access.
Figured that out by having daily.local run a program called “treeps.pl” that puts out a tree-oriented process list. From that, you can work back up the tree to see who ran “daily.local”. You can find treeps.pl here: https://apple.stackexchange.com/questions/11770/linux-ps-f-tree-view-equivalent-on-osx (search for “treeps”, not “pstree”).
I hope I stuffed enough good keywords in there to save someone the time it took me to track that down!
This may be helpful if you are trying to replicate the tree command on Mac too:
I upgraded an unsupported machine (MacPro 4,1) to Mojave using the DosDude1.com patch, and now my numerous Ruby scripts won’t work.
That didn’t help, so I change all my scripts to refer to the Homebrew version, by making “#!/usr/local/opt/ruby/bin/ruby” the first line. Still no joy.
When trying to run any ruby script, I get:
/usr/local/opt/ruby/bin/ruby: bad interpreter: Operation not permitted
However, strangely enough, I CAN do “/usr/local/opt/ruby/bin/ruby Charmaine says:
this worked for me! thank you so much!
Bonjour j’ai un soucis avec mon terminal je suis mac os Hugh sierra 10.13.6 je voudrais faire reconnaitre ma carte USB wifi a partir de mon terminal avec cette instruction sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /System/Library/Extensions/RT2870USBWirelessDriver.kext/Contents/Info.plist demandant mon mot de passe administrateur après mon mot de passe il écrit Illégal instruction:4 que faire
Just like Jeff and Marius before me I couldn’t get rid of the ‘Operation not permitted’ error despite following these instructions.
Is there anything else I can try?
What worked for me at the end was to add “/bin/bash” to the list of Full Disk Access. (After hitting “+” in Step 5 above, hold “Cmd-Shift-G” and type “/bin”, then click on “bash”.)
I have seen the posts about “how to add users to the sudoers list”, but if I have no sudoers, I can’t execute any SUDO commands. Ho can I add a sudoer without using terminal “sudo” command.
Thanks Paul, Terminal in OSX is working now, but when SSH to mac it still says Operation Not Permitted when listing some directories.
Tried adding /bin/ssh and sbin/sshd if I remember correctly still same problem. Any clues? Thanks!
Thank you for this tip, was very helpful and easy. I ran in to this issue after updating to Catalina and it helped me.
I was getting below error and it is fixed now.
Thanks so much for posting this and making it very easy to understand, it helped fix my problem on my own Mac, as well as my mom’s MacBook. It’s so great to have forms like this to help fix problems that Apple has made.
Glad this could help you resolve your issue with “Operation not permitted” errors in MacOS, thanks for reading! This applies to Catalina too.
Gracias, i was facing the issue after i upgraded to Mac OS Catalina, and ur fix worked for me.
Thanks for publishing the solution. It solved my problem.
I can confirm what Jeff said. After adding Terminal to the Full Disk Access List, and restarting it (even rebooting), I still see:
$ cd /usr
myprompt:/usr$ sudo chown myuser:staff local/
Password:
chown: local/: Operation not permitted
myprompt:/usr$
This doesn’t appear to work for certain files or folders. After giving full disk access to Terminal, as described, and restarting Terminal:
jeffsidell$ cd /usr/bin
Jeffs-MacBook-Pro-2:bin jeffsidell$ sudo mv python python2.7.10_JPS_mv_python
Password:
mv: rename python to python2.7.10_JPS_mv_python: Operation not permitted
I do NOT want to give terminal full disk access for ALL users. I want to give terminal full disk access ONLY for root. Is there a way to do that?
Thanks budy, this really solved my terminal issues with “Operation not Permitted”.
I did the first few steps but I can’t find the Full Disk Access option. Help
Same here can’t find the Full Disk Access. Help us 🙁
Couldn’t also find the Full Disk Access.
First you could try emptying the trash securely. [Finder->Secure Empty Trash…].
If that doesn’t work, go to the terminal and navigate to the trash folder. It will probably be in [/Users/your_user_name/.Trash].
If that doesn’t work, you will have to disable SIP (System Integrity Protection)
I had the same problem. Like stargood said, you probably have to disable SIP (see link in this article). This should let you delete the files.
Don’t forget to turn it on afterwards, if you don’t explicitly need it off.
For anyone writing a shell script that’s run by `cron`, e.g. you use `rsync` in a script to backup your files on another server…
You will notice that adding “Terminal.app” to the “Full Disk Access” does not work, because cron does not use “Terminal.app”.
Now you could grant “Full Disk Access” access to the `rsync` program, and that solves some of the permission problems, but this is not enough if you need access to:
Instead, you should add `cron` to “System Preferences > Security & Privacy > Full Disk Access”.
I did this by running `open /usr/bin/`, which opened a Finder window that allowed me to easily drag/drop the `cron` program into the “Full Disk Access” list.
After one year your post saved my scripts life 😉
After 1.5 years, this helped resolve my issue as well. Thanks.
If you expect “security” and “privacy” in a closed source operating system, you’re a lost cause anyways. If you aren’t even allowed to understand how your online banking balance was being rendered on your screen, you should overthink your ways. Remember: If the number on your online banking page is all wrong, you’re going to starve. So this isn’t some “minor thing only nerds should care about”.
Security in Mac OS X. Pff.
These new “security” features and alerts of 10.14 are nothing more than annoying and unnecessary tactics to trick fools into believing they’re safe. Apple calls these things “features”, but for skilled administrators those are nothing more than “bugs”, simply put. Because they break stuff. Render it unusable, unless intervened.
After having migrated from an earlier macOS/Mac OS X release to 10.14, you’ll find your Macintoshes automation techniques struggling hard. In order to get your deserted Mac up and running again, I suggest the following:
Doesn’t fix every annoyance, as it won’t mute alerts that will pop up from applications and executables you’ll install in the future, but it is a step forward.
And please don’t give me crap about how I lure users into doing “dangerous” things. Keep your security hysteria to yourself. If Mac OS X managed to strive without a malware epidemic from 2001 until now, it will continue to do so, even if you enable the “evil evil” disk access.
I’m critically fed up with Apple in 2018. We’re reaching idiocy and greed levels that shouldn’t be possible.
Rather than complaining and moaning, why don’t you simply disable System Integrity Protection? It takes like two minutes, tops. *eyeroll*
Источник
View Full Version : [SOLVED] Zipping Multiple Files into Multiple Archives from Terminal
rfry11
December 3rd, 2010, 12:10 AM
After learning that the VisualBoy Advance from the Ubuntu repositories can load .ZIP archived ROM files, I’m interested in archiving all of my ROM files into .ZIP files.
Does anyone know a good terminal command to get this done quickly and efficiently?
To better describe what I’m asking, I want every ROM file (.GBC files) in its own .ZIP file.
Example:
Put the files «007 — The World is Not Enough (UE).gbc», «Catwoman (U).gbc», and «International Rally (U).gbc» into zip archives entitled «007 — The World is Not Enough (UE).gbc.zip», «Catwoman (U).gbc.zip», and «International Rally (U).gbc.zip»
By my calculations this will reduce the file size by half, and would greatly help me. I won’t individually zip them if there’s no easy way to do it, it’s not worth 400mb of extra space for an afternoon’s work.
HiImTye
December 3rd, 2010, 12:14 AM
you could try something like
ls | grep gbc | zip -9
rfry11
December 3rd, 2010, 12:24 AM
I’m getting an error when I run this command.
$ ls | grep gbc | zip -9
zip error: Invalid command arguments (cannot write zip file to terminal)
Am I lacking something in my install, or inputting the command incorrectly?
EDIT:
Just searched for my error on Google, and found this page (http://zotline.com/shownote.zot/NoteNum/4419.html), where it says that I have to «give the name of the zipfile you want to create on your command line.». Any way to have the zip program generate names based off of the file’s names?
mdgtptrl
December 3rd, 2010, 12:56 AM
your best bet may be to write a shell script to do it using foreach and basename to generate new filenames, and pass those to zip
#!/bin/bash
files=`find *.gbc`
for file in $files
do
newname=»`basename $file .gbc`.zip»
zip $newname $file
done
rfry11
December 3rd, 2010, 02:04 AM
Thanks a lot for the idea of using a bash script, but unfortunately yours doesn’t seem to work.
When I run it inside the directory, I get a lot of these sorts of errors:
zip error: Nothing to do! (Duel.zip)
zip warning: name not matched: Stories
zip error: Nothing to do! (Stories.zip)
zip warning: name not matched: (U).gbc
zip error: Nothing to do! ((U).zip)
zip warning: name not matched: Zebco
zip error: Nothing to do! (Zebco.zip)
zip warning: name not matched: Fishing!
zip error: Nothing to do! (Fishing!.zip)
zip warning: name not matched: (U).gbc
zip error: Nothing to do! ((U).zip)
zip warning: name not matched: Zoboomafoo
zip error: Nothing to do! (Zoboomafoo.zip)
zip error: Invalid command arguments (short option ‘.’ not supported)
zip warning: name not matched: Playtime
zip error: Nothing to do! (Playtime.zip)
zip warning: name not matched: in
zip error: Nothing to do! (in.zip)
zip warning: name not matched: Zobooland
zip error: Nothing to do! (Zobooland.zip)
zip warning: name not matched: (U).gbc
I don’t really know enough about bash to know what the problem is, but I’ve been looking around trying to learn how it all works.
Do you know why it wouldn’t be working?
SeijiSensei
December 3rd, 2010, 02:37 AM
Perhaps you don’t have zip installed? (sudo apt-get install zip)
rfry11
December 3rd, 2010, 03:11 AM
Just checked — I’ve got the newest version.
DaithiF
December 3rd, 2010, 09:53 AM
the script above won’t work for files with spaces in the names (of which you have plenty).
an improved version would be something like:
#!/bin/bash
for file in *.gbc
do
zip «${file}.zip» «$file»
done
KiLaHuRtZ
December 3rd, 2010, 09:57 AM
How about a one line’r …
ls /path/to/your/roms | grep .gbc | while read file; do zip «${file}».zip «${file}»; done
DaithiF
December 3rd, 2010, 10:37 AM
why use 2 external commands ls and grep to do what the shell itself can do?
for file in *.gbc; do zip «${file}.zip» «$file»; done
KiLaHuRtZ
December 3rd, 2010, 11:03 AM
No wrong way to do it. :-k That’s the beauty of *NIX!
You could compile a file list first and use cat instead of ls and pipe that into a while loop.
KiLaHuRtZ
December 3rd, 2010, 11:07 AM
Or, use caution, …
locate .gbc | while read file; do zip «${file}».zip «${file}»; done
rfry11
December 3rd, 2010, 12:22 PM
Wow guys, thanks a lot.
I started from the last post, made by KiLaHuRtZ, but unfortunately his command…
locate .gbc | while read file; do zip «${file}».zip «${file}»; done
…failed to do anything, no errors or anything.
However, DaithiF’s command…
for file in *.gbc; do zip «${file}.zip» «$file»; done
…works perfectly, and did exactly what I was looking for!
I did not test the other two that you guy’s posted, I think DaithiF’s command is as simple as you can get, and it’ll definitely help out if I ever have a problem like this again.
And, thanks a lot, and I’m going to mark this as solved.
KiLaHuRtZ
December 4th, 2010, 12:34 AM
Glad to hear it! DaithiF’s is simpler for a single directory. The last one I posted should find all files with «.gbc» included in the string and zip them. Since it didn’t work for you, my guess is that you power down often and may need to update the DB for the system to find them. Hence, run this first…
sudo updatedb
locate .gbc | while read file; do zip «${file}».zip «${file}»; done
rfry11
December 4th, 2010, 08:00 PM
Ah yes, your command does work now. Thanks a lot for explaining that little problem.
Just to simplify for anyone stumbling over this in the future:
If all of the files you want to Zip are located in one directory, run this command:
for file in *.gbc; do zip «${file}.zip» «$file»; done
…And if the files you want to Zip are located in various directories, run this command:
sudo updatedb
locate .gbc | while read file; do zip «${file}».zip «${file}»; done
In the event you want to Zip files that are not .GBC files, replace .GBC with their file extension.
And of course, a lot of thanks to KiLaHuRtZ and DaithiF!
Powered by vBulletin® Version 4.2.2 Copyright © 2023 vBulletin Solutions, Inc. All rights reserved.