GBase 8a之加载数据跳过尾行的方法 加载数据跳过尾行的方法load data 暂不支持跳过尾行加载。遇到大文件加载时加载前可先用以下脚本删除待加载文件的末尾行考虑到大文件的处理效率用truncate。脚本如下large_file/opt/1.dat # 1. 获取文件总字节数 total_size$(stat -c %s $large_file) # 2. 获取最后一行内容 last_line$(tail -n 1 $large_file) # 3. 计算最后一行的实际字节数含特殊字符/多字节字符 # echo -n 避免额外添加换行符wc -c 精确统计字节数 last_line_bytes$(echo -n $last_line | wc -c) # 4. 判断最后一行末尾是否有换行符\n 占1字节 # 取文件最后1字节转换为十六进制\n的十六进制是0a last_char$(tail -c 1 $large_file | od -An -t x1) if [ $last_char 0a ]; then newline1 # 有换行符占1字节 else newline0 # 无换行符 fi # 5. 计算需要保留的字节数总大小 - 最后一行字节数 - 换行符字节数 keep_size$((total_size - last_line_bytes - newline)) # 6. 截断文件 truncate -s $keep_size $large_file