1

How to split large files into parts with .001 .002 (and so on) extension in CentOS via SSH Terminal (using Putty)?

For example, if I have a large file - LargeFile.iso, then how can I be able to split it into files like LargeFile.iso.001, LargeFile.iso.002, LargeFile.iso.003, LargeFile.iso.004.... and so on till LargeFile.iso.xxx (where xxx is the last part)?

4

Split is your friend with options:

-d --numeric-suffix  for numerical suffixes
-a -- suffix-lenght  for suffix lenght

Give a look at

split --help

in terminal

0

The best way might be a short bash script along the lines of

#!/bin/bash

BS=1024
SEGMENT=100000

LEN=$(ls -l | awk '{ print $5; }')
BL=$(($LEN/$BS))
S=0
I=1
while test "$BL" -le "$S"; do
  dd if="$1" of="$1."$(printf '%03d' $I) bs="$BS" skip="$S" count="$SEGMENT" 2>/dev/null
  S=$(($s+$SEGMENT))
  I=$(($I+1))
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.