Why you don't need HJSplit for Linux

HJSplit is famous in the DOS/Windows world as a way to split/join large files for easy network transfer. I’m just confused why they bothered to make an HJSplit version for linux. This HJSplit for Linux even requires you to install a separate library which add to the garbage for such a useless app (for nix). If you’re on linux and you encounter a file split via HJSplit, just use the venerable `cat` and you’d be fine.

cat split-files.rar.* > split-files.rar
This entry was posted in Unix One-Liners and tagged , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

42 Comments

  1. Sam
    Posted September 21, 2007 at 20:00 | Permalink

    Thanks for the tip!

  2. Ofer
    Posted October 4, 2007 at 22:07 | Permalink

    the best tip I’ve got

  3. Arc
    Posted May 8, 2008 at 23:17 | Permalink

    Didn’t know this – thanks for pointing it out :-)

  4. Arc
    Posted May 9, 2008 at 17:37 | Permalink

    Now I’m just wondering how to easily split the file in linux so something like HJsplit in windows can join it together again.

    Messing about with the split command but the closest I’ve gotten is to have the files output starting at .000, instead of .001

  5. Posted May 17, 2008 at 10:28 | Permalink

    Arc:

    $ i=1;for file in splitfiles*; do mv $file $(printf “newfiles.%03i” $i);i=$((i+1)) ; done

    Didn’t bother re-using the old filename because it would just clobber the next file name if I do it like

    file.000 –> file.001 # will write over the original file.001

    so making a new filename is the best I can come up with in 5 minutes :)

    • Steve
      Posted August 7, 2011 at 18:34 | Permalink

      Unless you loop backwards, of course…

  6. Posted August 17, 2008 at 15:52 | Permalink

    Cant get any easier. Cheers for this!

  7. Posted September 11, 2008 at 14:16 | Permalink

    Nifty! I used it and it works fine. Thanks :D

  8. Posted September 13, 2008 at 01:04 | Permalink

    @Clair: Glad to help :)

  9. Rishabh
    Posted September 14, 2008 at 21:29 | Permalink

    Can’t belive that there is no cat equivalent in Windows… Cant this be done in DOS?

    • Steve
      Posted August 7, 2011 at 18:34 | Permalink

      Of course there isn’t – windows is a half-assed operating system that’s good enough for the layman.

      • Posted August 18, 2011 at 03:09 | Permalink

        Actually there is the “type” command but it’s not as powerful as cat (it can’t do binary concatenation). I’m not sure of the equivalent cmdlet in Windows Powershell.

      • Alex
        Posted January 13, 2013 at 02:34 | Permalink

        Of couse there is: copy /b file.001+file.002+file.003 resulting.file

    • Paul D
      Posted January 25, 2013 at 07:53 | Permalink

      I’d think you can use the old DOS construct of:

      copy /b file1.001 + /b file1.002 + /b file1.003 finalfile.ext

      • Posted March 26, 2013 at 07:43 | Permalink

        Thanks to Alex and Paul D for pointing this out via copy.

  10. Posted September 16, 2008 at 15:36 | Permalink

    You have the choice of installing cygwin.com. But why install cygwin when you can install hjsplit for windows.

    This is just for linux users who don’t want to install hjsplit for linux on their machines.

    You can try the “type” command in the command propt but I’m not sure if that will work.

    We’d like to hear if you are successful.

  11. Chuck
    Posted October 19, 2008 at 00:20 | Permalink

    One of the best tips I have come across. THANK YOU!

  12. Dimas
    Posted January 13, 2009 at 08:17 | Permalink

    Claps your hands and say yeahhh. Great tips.

  13. Posted January 14, 2009 at 14:02 | Permalink

    great tip. i rate this as one from a “guru”. thanks. but i can not figure out the script that would split the file. where are we specifying the number of parts we would like to split the file into ?

  14. Posted January 15, 2009 at 15:31 | Permalink

    @aman: that’s easy. to split the file use bash’s split command.

    split -da 3 bigfile.pdf splitfiles

    (‘man split’ for more info on the useful split command)

    the command:

    i=1;for file in splitfiles*; do mv $file $(printf “newfiles.%03i” $i);i=$((i+1)) ; done

    is just used to rename the files so the first splitfile has .001 has its extension instead of .000 which is the default for the split command.

    Because HJSplit only detect files starting with .*1 as its first file (which is weird in computerland where everything should start with 0).

    I guess you can make a better version using Perl/Python/Ruby/etc that will split files into HJSPlit named formats but I’m lazy so the above will work anytime, everytime without you breaking a sweat.

  15. Posted January 15, 2009 at 16:51 | Permalink

    thanks a million. i honestly feel “enlightened” :) this is a really neat feature that i can use. i was not aware of the split command and the script makes sense (to me) now.

  16. dooh
    Posted July 5, 2009 at 05:17 | Permalink

    I figured the files were just literally split and renamed, just shows how stupid people are that try to make you download this closed source HJSplit crap probably full of virii. Shh, don’t show them this page or they will insert headers and obfuscation in the split files!

    • Steve
      Posted August 7, 2011 at 18:35 | Permalink

      No worse than people who think “virii” is a word.

  17. Zac
    Posted January 11, 2010 at 04:25 | Permalink

    I’m new to Linux, and I just don’t get it, I guess. Joining split files is one of the first things I want to be able to do, and three weeks after upgrading to Linux, I still can’t.

    -I have the files SHANE.avi.001, SHANE.avi.002… SHANE.avi.007 in my home folder
    -I open a terminal
    -I type what, exactly?

  18. Posted January 11, 2010 at 11:24 | Permalink

    cat SHANE.avi.* > SHANE.avi

  19. Posted January 11, 2010 at 11:26 | Permalink

    ofcourse the terminal will have opened into the ~> directory, and you will have to do an “ls” to make sure the files are in the current directory. if not you will have to go to the directory where the files reside, using the “cd ” command

  20. Posted January 28, 2010 at 08:22 | Permalink

    @Zac: Aman’s right. Basically you just throw all the files at once to a single file.

    Read more about Bash output redirection.

    Like when you want to capture the directory listing into a single file, on the terminal you do:

    ls > dirlisting.txt

    That captures the output of the ‘ls’ command into a text file called ‘dirlisting.txt’.

    Now the great thing about redirection is it respects the file’s properties. It does not care if it’s binary or text.

    Split files are binary and when you ‘cat’ them (meaning you want to display their output) they remain binary. Just try “catting” a video file and you’ll hear all the beeps of the terminal.

    Another thing is that ‘cat’ if used with globbing (asterisks to denote “all-characters”) then it makes sure to do it in proper succession. Meaning, you don’t get the middle part into the first part and the last part into the middle part of the split file. It follows the name in succession to create the whole file (I hope you understood that because I don’t know how else to explain it :) ).

    Bash is a beautiful scripting language. It will open more possibilities for you to explore other scripting languages and are quite good for 30-second hacks.

    I suggest learning the language via the legendary “Advanced Bash Scripting Guide” by Mendel Cooper.

  21. Konfounded
    Posted February 1, 2010 at 08:23 | Permalink

    Can someone explain in laymans what the poster jedrm is trying to say with.

    “It follows the name in succession to create the whole file (I hope you understood that because I don’t know how else to explain it :) ).”

    Also, I’ve tried cat before but it ended up not working (or maybe I did it wrong), one day on my desktop I eventually downloaded lxsplit and it was a single binary, I dont recall it requiring another library.

    Anyhow, I normally would use Peazip archive browser on my laptop, as it has a built-in splitter and joiner that uses pea, and it works superbly with split files. Though now that I’ve read that the cat command works I will try again.

    • Posted February 12, 2010 at 14:54 | Permalink

      @Konfounded, not trying to sound snob but sometimes it’s worth trying to learn the basics first.

      What I was explaining with “It follows the name in succession…” is this:

      You have a file split into 5 parts.

      File.001
      File.002
      File.003
      File.004
      File.005

      If you know and read about Unix globbing and regular expressions, if you put an asterisk (*) in something it could mean anything an everything.

      So by doing a

      cat File.* > File

      You are simply doing

      cat File.001 File.002 File.003 File.004 File.005 > File

      without the need for redundant typing. And knows to follow it in succession without mixing up the arrangement of what part comes first.

      hope this helps

      • Konfounded
        Posted February 13, 2010 at 23:52 | Permalink

        jedrm,

        Oh, if that’s all you were saying then I understand that then, I guess it was a mix of your choice of diction and how that sentence was constructed, that confused me. English is not my primary language, excuse the confusion.

  22. Zac
    Posted February 5, 2010 at 06:36 | Permalink

    Sorry, I just don’t get it. How do I make sure the terminal is open in a particular directory? I’ve never read a book on Linux, and I knew practically nothing about it until my computer all but crashed a month and a half ago, and as a last-ditch effort, I saved my files on an external drive, wiped the hard disk and installed Ubuntu.

    • Konfounded
      Posted February 11, 2010 at 09:04 | Permalink

      You can make sure the Linux terminal is open by using commands.

      pwd
      cd

      individually the first command when typed into the terminal will (p)rint (w)orking (d)irectory…that is the directory your currently working in.

      the second command will (c)hange (d)irectory. So if you wanted to change directory use something like:

      cd /home/downloads/

      also, if you have a space in a title you are going to need to specify it….. the easiest method to overcome this for a newbie is to enclose the directory in quotes. such as:

      cd “/home/this directory has a lot of spaces”

      I suggest you google for a book on Linux or Unix tutorials there are so many free ones out there.

  23. Zac
    Posted February 12, 2010 at 14:23 | Permalink

    Thanks. How much of an expert do I have to be to use and enjoy Linux? I really just want to pick up women on the internet, and download Western movies and MILF foot fetish videos.

  24. junker
    Posted March 13, 2010 at 10:42 | Permalink

    There is an ms-dos concatenate command…

    Use:
    copy /b junk.mpg.001+junk.mpg.002 junk.mpg

    The /b flag uses binary concatenation, the default (/a) flag will end “assembly” if it encounters an EOF character – it was used to concatenate text files.

  25. wayne
    Posted April 10, 2010 at 03:57 | Permalink

    why does avi.001 files change to avi.001.txt when i’m downloading movies from the internet when having .txt makes it a useless file for hjsplit??

  26. Posted October 16, 2010 at 07:33 | Permalink

    Great !! it’s working….

  27. gregbob
    Posted December 14, 2010 at 00:03 | Permalink

    awesome!

  28. Posted October 11, 2011 at 17:58 | Permalink

    If its as simple as using cat, this should work.
    cat file.iso.00{1..8} >> file.iso (or whatever)

    Tried using cat on “HJSplitted” files, but didnt work out well. Strangely.

    Windows is a toy OS that is fine for toy computers and toy tasks. For real tasks, a real OS is needed.

    World should use open and free standards and throw HJSplit into the fire.. Crapware in my opinion.

  29. Posted October 11, 2011 at 18:14 | Permalink

    Well actually. Some broken file it seems, downloaded again, and merged it beautifully with cat.

    Fired up HJSplit with wine and did a md5sum to compare. And they are equal :)

    Then I have to retract the crapware statement. Id call it bloatware instead. Since it just complicates a simple task that no one needs dedicated program for. Not even windows users needs it, and that says a lot lol

    • Posted October 12, 2011 at 12:55 | Permalink

      I guess a lot of people feel more comfy when they can see a GUI and click on buttons.

      For a normal computer user, HJSplit fills a certain niche. But if you have any archiving tool (7-zip, WinRAR, WinZip, etc) then you can also split files using that.

      Of course `cat` would be for us folks who are too lazy to grab the mouse and let go of our keyboards :)

  30. Posted March 13, 2013 at 10:12 | Permalink

    How if I split large file on Linux to be multiple small files, then I join them using HJSplit on Windows, is that possible?

    • Posted March 26, 2013 at 07:46 | Permalink

      Hi Anton,

      Yes you can. Check in the comments about how to use Linux split command.

One Trackback

  1. By Cat for connecting files broken down via HJSplit on September 11, 2008 at 15:50

    [...] to the blog post of Jed about why you don’t need HJSplit for Linux. I’ve never really had the need to split files nor join files until [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

Connect with Facebook

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>