Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7405001
  • 博文数量: 1756
  • 博客积分: 18684
  • 博客等级: 上将
  • 技术积分: 16232
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-02 10:28
个人简介

啥也没写

文章分类

全部博文(1756)

文章存档

2024年(2)

2023年(44)

2022年(39)

2021年(46)

2020年(43)

2019年(27)

2018年(44)

2017年(50)

2016年(47)

2015年(15)

2014年(21)

2013年(43)

2012年(143)

2011年(228)

2010年(263)

2009年(384)

2008年(246)

2007年(30)

2006年(38)

2005年(2)

2004年(1)

分类: LINUX

2009-03-06 09:32:06

#!/bin/sh
do_help()
{
    echo "syntax:"
    echo "split "
}
orig_file=$1
split_num=${2:-2}
dest_path=${3:-.}
if ! ( [ -f "$orig_file" ] &&
[ -r "$orig_file" ] && [ -s "$orig_file" ] ); then
    echo "file $orig_file is invalid."
    do_help
    exit 1
fi
if ! [ $split_num -gt 1 ]; then
    echo "split_num is invalid."
    do_help
    exit 1
fi
if ! ( [ -d $dest_path ] && [ -x $dest_path ] );then
    echo "dest_path is invalid."
    do_help
    exit 1
fi
size=$(ls -l $orig_file | awk '{print $5}')
split_size_avr=$(($size/$split_num))
bs=1
if [ $size -gt $((1024*1024)) ]; then
    bs=1024
    split_size_avr=$(($split_size_avr/1024))
fi
for i in $(seq $split_num);do
    if [ $i -eq 1 ]; then
        dd if=$orig_file \
of=$dest_path/${orig_file}.$i bs=$bs count=$split_size_avr
    elif [ $i -eq  $split_num ];then
        dd if=$orig_file \
of=$dest_path/${orig_file}.$i bs=$bs \
skip=$(($split_size_avr*$(($i-1)))) \
count=$(( $size - $(($split_size_avr*$(($i-1)))) ))
    else
        dd if=$orig_file \
of=$dest_path/${orig_file}.$i bs=$bs \
skip=$(($split_size_avr*$(($i-1)))) \
count=$split_size_avr
    fi
done
命令格式:
./split filename N dest_path
合并N个小文件为一个大文件:
代码:
cat $(ls |grep -E 'filename\.') > filename
阅读(1174) | 评论(1) | 转发(1) |
0

上一篇:shell菜单

下一篇:AutoSetup系列-------AutoMAP

给主人留下些什么吧!~~

chnljx2009-03-09 13:19:23

寻求合作创业伙伴! 如果您是软件开发的高手,又不愿安于现状,创业应该是个不错的选项,因为一不小心就会又弄出个年度风云人物。但高回报总是伴随着高风险,高科技创业的成功率太低了,只有百分之几。不要沮丧,老哥我的加入会使得成功率提升十倍,太牛了点吧!但如果是:二十多年的管理经验+企业管理中、高级各个岗位的历练+高级管理顾问师,不算牛吧。本人已经看好一个方向,就是PM(个人管理),需要通过软件系统来实现,急于寻求合作伙伴。由于个人原因,创办的企业限在江苏或上海,有意者请联系,非诚勿扰!QQ:935417531,手机:13852659556,邮箱:chnljx@163.com。