split Command in Linux

Learn via video courses
Topics Covered

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Overview

The split command in Linux is a highly useful tool for dividing large files into smaller, more manageable pieces. This command is often used in scenarios where you need to break down a large file for easier data processing or distribution. In this article, we'll dissect the split command, its syntax, options, and some practical examples of its usage.

Syntax of split Command in Linux

The basic syntax of the split command in Linux is as follows:

Where:

  • OPTIONS: These are optional parameters that modify the behavior of the split command.
  • FILE: This is the input file that you want to split.
  • PREFIX: This parameter specifies the prefix for the output files. The default prefix is 'x'.
Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course

Options in split Command in Linux

  1. -b, --bytes=SIZE: This option lets you specify the size of each output file.

    For example -

    Output:

    This command splits the 'largefile.txt' into multiple files of size 500KB each.

  2. -l, --lines=NUMBER: This option lets you specify the number of lines for each output file.

    For example -

    Output:

    This command splits the 'largefile.txt' into multiple files, each containing 1000 lines.

  3. -a, --suffix-length=N: This option lets you specify the length of the suffix in the output files.

    For example -

    Output:

    This command splits the 'largefile.txt' into multiple files, each having a 3-character suffix.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Example Usages

  • Basic usage of split command.:

    Output:

    Explanation: The split command, without any options, splits the input file into multiple files, each containing 1000 lines.

  • Splitting a file into specific byte size.:

    Output:

    Explanation: The split command, with -b option, splits the input file into multiple files, each of 1MB size.

Tips

  • Always backup your original files before using the split command.

  • You can use the cat command to join the split files back together.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Advanced Use Cases of split Command in Linux

  • Splitting a file and specifying a custom prefix.:

    Output:

    Explanation: The split command splits the input file into multiple files, each prefixed with 'customprefix'.

  • Splitting a file into specific line count with custom suffix length.:

    Output:

    Explanation: The split command splits the input file into multiple files, each containing 2000 lines and having a 4-character suffix.

  • Splitting a file using a combination of options.:

    Output:

    Explanation: The split command splits the input file into multiple files, each containing 5000 lines and having a 2-character suffix, with the suffixes numbered instead of alphabetical.

Conclusion

  • The split command in Linux is a powerful tool for dividing large files into smaller, manageable pieces.

  • The syntax of the split command includes options, file, and prefix, each serving a different purpose.

  • Key options of the split command include -b for byte size, -l for line count, and -a for suffix length.