Using Awk to split files

Created on 2022-10-06T07:43:12-05:00

Return to the Index

This card pertains to a resource available on the internet.

This card can also be read via Gemini.

# send each line to a file named after the value of the second column
awk -F, '{ print > $2 ".csv" }' file.csv
# only split when the second field has one of a set value
awk -F, '$2 == "577" || $2 == "132" { print > $2 ".csv" }' file.csv