Search This Blog

Total Pageviews

Thursday 1 August 2024

Unix split command


 Unix split command 




Created 1gb file for testing 

dd if=/dev/urandom of=anuj.trc bs=64M count=16 iflag=fullblock
16+0 records in
16+0 records out
1073741824 bytes (1.1 GB) copied, 65.8006 s, 16.3 MB/s


[oracle@rac01:~] $ls -ltr anuj.trc
-rw-r--r-- 1 oracle oinstall 1073741824 Aug  1 04:46 anuj.trc

[oracle@ibrac01:~] $ls -lhtr anuj.trc
-rw-r--r-- 1 oracle oinstall 1.0G Aug  1 04:46 anuj.trc


Split the file 400m chunks

[oracle@rac01:~] $

tar cz anuj.trc | split -b 400m - anuj.trc_split


rac01:~] $ls -ltrh anuj*

-rw-r--r-- 1 oracle oinstall 1.0G Aug  1 04:46 anuj.trc
-rw-r--r-- 1 oracle oinstall 400M Aug  1 04:49 anuj.trc_splitaa
-rw-r--r-- 1 oracle oinstall 400M Aug  1 04:49 anuj.trc_splitab
-rw-r--r-- 1 oracle oinstall 225M Aug  1 04:50 anuj.trc_splitac

delete the old file to test !!!
rm anuj.trc

To Join 
cat anuj.trc_split* | tar xz


ls -ltrh anuj*

-rw-r--r-- 1 oracle oinstall 1.0G Aug  1 04:46 anuj.trc  <<<<<----Now file is back 
-rw-r--r-- 1 oracle oinstall 400M Aug  1 04:49 anuj.trc_splitaa
-rw-r--r-- 1 oracle oinstall 400M Aug  1 04:49 anuj.trc_splitab
-rw-r--r-- 1 oracle oinstall 225M Aug  1 04:50 anuj.trc_splitac


No comments:

Oracle DBA

anuj blog Archive