make a unix oneliner that can zip all folders in the current directory to their own…
- User
make a unix oneliner that can zip all folders in the current directory to their own separate archives
- Assistant
The following UNIX one-liner can be used to zip all folders in the current directory to their own separate archives:
for dir in */; do zip -r "${dir%/}.zip" "$dir"; doneThis one-liner uses a
forloop to iterate through each directory (*/) in the current directory. For each directory, it runs thezipcommand to recursively (-r) create a zip archive with the same name as the directory ("${dir%/}.zip") and includes all files and subdirectories within the directory ("$dir"). The trailing/in"$dir"is removed using the${dir%/}expression to ensure that the name of the zip archive does not include a trailing slash.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.