2014년 1월 16일 목요일

command to zip multiple directories into individual zip files

http://unix.stackexchange.com/questions/68489/command-to-zip-multiple-directories-into-individual-zip-files

for i in */; do zip -r "${i%/}.zip" "$i"; done

i is the name of the loop variable. */ means every subdirectory of the current directory, and will include a trailing slash in those names. Make sure you cd to the right place before executing this. "$i" simply names that directory, including trailing slash. The quotation marks ensure that whitespace in the directory name won't cause trouble. ${i%/} is like $i but with the trailing slash removed, so you can use that to construct the name of the zip file.

If you want to see how this works, include an echo before the zip and you will see the commands printed instead of executed.

댓글 없음:

sublime close without confirmation

  Close without confirm   Yes, you can just write a plugin to set the view as scratch and close it. Then create a keybinding for that c...