Created
October 7, 2024 15:05
-
-
Save greenido/bd8f563b554b77eb2e8ad65246ed4be4 to your computer and use it in GitHub Desktop.
concat csv files - Up to 5 :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Output file name | |
output_file="combined_table_data.csv" | |
# Keep the header from the first file | |
head -n 1 "table_data.csv" > "$output_file" | |
# Function to remove header and append content | |
append_without_header() { | |
tail -n +2 "$1" >> "$output_file" | |
} | |
# Append all files without their headers | |
append_without_header "table_data.csv" | |
append_without_header "table_data (1).csv" | |
append_without_header "table_data (2).csv" | |
append_without_header "table_data (3).csv" | |
echo "All CSV files have been combined into $output_file" | |
# Optional: Count total lines in output file | |
echo "Total lines in combined file: $(wc -l < "$output_file")" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment