我们如何分别GZip每个文件?
我不想把所有文件放在一个大焦油中。
答案 0 :(得分:61)
您可以使用gzip *
注意:
-k
(--keep
)选项保留原始文件。 答案 1 :(得分:25)
简单而快速的答案将并行使用所有CPU内核:
/*-------------------------------------
STEP ONE: PLACE BID
--------------------------------------*/
$.ajax({
url: "https://sheetsu.com/apis/4a8eceba",
method: "GET",
dataType: "json"
}).then(function(spreadsheet) {
// Print current bid
var currentBid = spreadsheet.result.pop().Bids;
$(".current__amount").html("$" +currentBid);
$('.button__form').on('click', function() {
var value = $(this).val();
if($(this).hasClass('is-selected')) {
$(this).removeClass('is-selected');
$(".check--one").css("color", "#ccc");
currentBid = parseInt(currentBid) - parseInt(value);
}
else {
$(this).addClass('is-selected');
$(".check--one").css("color", "#ffdc00");
currentBid = parseInt(currentBid) + parseInt(value);
}
$('.total__amount').html("$" + currentBid);
});
});
GNU Parallel 是一个很棒的工具,应该在这个世界中使用得更多,其中CPU只获得更多内核而不是更快的速度。有大量的例子,我们都可以花10分钟阅读...... here
答案 2 :(得分:17)
七年后,这个备受好评的评论仍然没有自己的全面答案,所以我现在就推广它:
gzip -r .
这比目前接受的答案有两个优点:如果有任何子目录,它会递归工作,如果文件数量非常大,它就不会从Argument list too long
失败。
答案 3 :(得分:13)
如果你想递归地gzip每个文件,你可以使用find piped to xargs:
$ find . -type f -print0 | xargs -0r gzip
答案 4 :(得分:5)
尝试循环
$ for file in *; do gzip "$file"; done
答案 5 :(得分:0)
或者,如果您有pigz(gzip实用程序,可在多个处理器和内核上并行化压缩)
def is_prime(n):
m = int(n)
for i in range(2,m-1):
if (m%i) == 0:
return False
return (True if m>1 else False)
def rotate(n):
list = []
string = str(n)
for i in string:
front = string[0]
rest = string[1:]
complete = rest + front
list.append(complete)
string = complete
return list
def rotations(num):
numString = str(num)
counter = 0
while counter < len(numString):
for i in numString:
rotater = rotate(i)
if is_prime(rotater) in numString == True:
counter+=1
return counter
print(rotations(1000))
答案 6 :(得分:0)
以下命令可以在一个目录中多次运行(没有 "already has .gz suffix"
警告)以 gzip 任何尚未 gzip 的内容。
find . -maxdepth 1 -type f ! -name '*.gz' -exec gzip "{}" \;
使用 find
的一个更有用的例子是当您想要 gzip 滚动日志时。例如。您希望每天或每月 gzip 滚动日志而不是当前日志。
# Considering that current logs end in .log and
# rolled logs end in .log.[yyyy-mm-dd] or .log.[number]
find . -maxdepth 1 -type f ! -name '*.gz' ! -name '*.log' -exec gzip "{}" \;