Sarathlal N

Split a Single CSV File into Multiple Files Using the Split Command - Bash

Working with huge CSV files? Need to split them for easier management and analysis? Look no further - I will show you how to split large CSV files using the split command in Bash. This quick guide will help you split your data like a pro!

Step 1: Open Your Terminal

To begin splitting your CSV files, open your terminal. You can use split in Bash on Linux, macOS, or Windows with WSL (Windows Subsystem for Linux).

Step 2: Navigate to the File’s Directory

Navigate to the directory where your CSV file is located using the cd command:

cd /path/to/your/csv/directory

Step 3: Splitting the CSV File

Use the split command to divide your CSV file by specifying the number of lines in each new file:

split -l 1000 large_data.csv smaller_data_

This command will split large_data.csv into smaller files, each containing 1000 lines. The new files will be named smaller_data_aa, smaller_data_ab, smaller_data_ac, and so on.

Step 4: Verify the Split

To confirm that the split was successful, list the files in your directory:

ls

Recent Posts

  1. Automating Release Generation with GitHub Actions
  2. WP CLI Commands to Bulk Delete Entries in WordPress Database
  3. Migrating code repo from BitBucket to GitHub
  4. Streamlining Development - Our Journey with Git, Bitbucket, and Jira
  5. The Amazing Adventure - Solving the Mysteries of a WooCommerce Store

Your Questions / Comments

If you found this article interesting, found errors, or just want to discuss about it, please get in touch.