Skip to main content

Posts

Showing posts from August, 2025

Shell Script - Filter / Extract Lines {Quick & Dirty}

Hey! Recently ran into a unique problem - had a csv file that was too large to open!  Well technically.....it opened....but.....all of the data couldn't be displayed. Then I remembered I had a linux box I use for exactly this type of thing!  Whipped up a quick & dirty script below. It reads the entire csv file, matches the lines that meet the specified criteria, and writes those line items into a new csv file.  May not be the best or most efficient, but it works. See script below: #!/bin/bash input_file="data.csv" output_file="filtered.csv" # Print header and then matching lines (head -n 1 "$input_file" && grep "Call Data" "$input_file") > "$output_file" echo "Done. Header and matched lines saved to $output_file." Remember... chmod +x