Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Commands»Split Command in Linux With Examples (Split Large Files)

    Split Command in Linux With Examples (Split Large Files)

    By RahulFebruary 6, 20233 Mins Read

    The split command in Linux is a useful tool for splitting large files into smaller parts. This is useful when dealing with large files that are too big to be transferred or managed easily. The split command can be used to split a file based on a specified size or line count, making it an ideal tool for breaking down large files into more manageable parts.

    Advertisement

    In this tutorial, we will cover the basics of the split command, including its syntax and options, to help you understand how it works and how to use it effectively.

    Syntax

    The basic syntax for the split command is as follows:

    1
    split [options] [input-file] [prefix]

    Here:

    • `[options]`: The options specify how the file should be split, such as the size or line count for each split file.
    • `[input-file]`: The input file is the file that you want to split.
    • `[prefix]`: The prefix is the name that will be given to the split files, followed by a suffix (e.g. xaa, xab, etc.).

    Options:
    Here are some of the most commonly used options for the split command:

    • -b size: Specifies the size of each split file, in bytes. For example, -b 100M will split the file into 100 MB parts.
    • -l lines: Specifies the number of lines in each split file. For example, -l 1000 will split the file into parts with 1000 lines each.
    • -a suffix_length: Specifies the length of the suffix used for the split files. The default suffix length is 2.

    Examples

    Let’s go through a few examples to see how the split command works in practice.

    1. Split a file into 100 MB parts
    2. split -b 100M file.txt split_ 
      

      This command will split the file file.txt into parts with a maximum size of 100 MB each, and the split files will be named split_aa, split_ab, etc.

    3. Split a file into 1000 line parts
    4. split -l 1000 file.txt split_ 
      

      This command will split the file file.txt into parts with a maximum of 1000 lines each, and the split files will be named split_aa, split_ab, etc.

    5. Change the suffix length
    6. split -a 3 -b 100M file.txt split_ 
      

      This command will split the file file.txt into parts with a maximum size of 100 MB each, and the suffix length will be 3 characters. The split files will be named split_aaa, split_aab, etc.

    7. Change the file prefix
    8. split -a 3 -b 100M file.txt backup_ 
      

      This command will create the splitter file, that name will begin with “backup_” prefix. You can change this with any string of your choice. Which will be used as an identifier of the files.

    Conclusion

    In conclusion, the split command in Linux is a versatile and useful tool for splitting large files into smaller parts. By understanding its syntax and options, you can effectively split files based on size or line count, making it easier to manage and transfer large files. Whether you’re backing up data or transferring large amounts of data between systems, the split command is a valuable tool to have in your Linux toolkit.

    command split
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    cp Command in Linux (Copy Files Like a Pro)

    dd Command in Linux (Syntax, Options and Use Cases)

    Top 10 JQ Commands Every Linux Developer Should Know

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Python Lambda Functions – A Beginner’s Guide
    • 10 Practical Use Cases for Lambda Functions in Python
    • Implementing a Linux Server Security Audit: Best Practices and Tools
    • cp Command in Linux (Copy Files Like a Pro)
    • 15 Practical Examples of dd Command in Linux
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.