I have a single tar file containing about 19 million files (no folders)
0000107b869682826003b04a40e6394.txt
00029237482s8923789423ud8923892.txt
2c002y8378723887292377a79237649.txt
f598238209237408238742308374038.txt
how do I untar all the files such that they appear in subdirectories named after the first four chars of the files. So for the example above, it would create 0000
, 2c02
, and f599
directories and each would have the following files.
0000\0000107b869682826003b04a40e6394.txt
0002\00029237482s8923789423ud8923892.txt
2c02\2c002y8378723887292377a79237649.txt
f598\f598238209237408238742308374038.txt
I've already tried creating a script that goes through the files in the tar file, creates a directory and extracts that file from the tar and puts it in the directory. This works for small number of files, but when the tar has millions, extracting takes a really long time.