我正在尝试整合具有unix时间戳和文件(part-00000)的文件夹,并写入日期文件夹中的单个输出文件。
输入文件夹和文件:
foldername filename
test-f1-1521144092000 part-00000
test-f1-1521141599000 part-00000
test-f1-1521143438000 part-00000
test-f1-1521140713000 part-00000
test-f1-1521204380000 part-00000
test-f1-1521204480000 part-00000
test-f1-1521204490000 part-00000
预期产出:
folder file
20180315 part-00000
20180316 part-00000
答案 0 :(得分:1)
bash
解决方案:
#!/bin/bash
for f in test-f1-[0-9]*/part-00000; do
d=$(dirname $f)
d=$(date -d"@${d:8:10}" +'%Y%m%d')
mkdir -p "$d"
cat "$f" >> "${d}/part-00000"
done