iam writing korn script. want size of file , store in variable in script. dont knw how size number variable if file of size 5gb variable must have 5 in it.
also if size of file exceeds 5gb should split 2gb files.
example: let file name file1 , size 5.6gb. file should split 3 files , naming of files should file1, file2, file3
can me please??
you can use du -bg <file>
size in gb.
hence, can do:
size=$(du -bg your_file | cut -dg -f1)
and then
[ $size -ge 3 ] && split -d -b2g your_file file
which give files like
file00 file01
explanation
[ $size -ge 3 ] && split -d -b2g your_file file ---------------------------------------------------------------------- condition of size split your_file in blocks of 2gb (-b2g) >=3 gb name "file" numerical suffix (-n)
Comments
Post a Comment