Skip to content

Instantly share code, notes, and snippets.

@huevos-y-bacon
Created January 18, 2024 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huevos-y-bacon/64cd96a66c4c328e74da3888d2b703ca to your computer and use it in GitHub Desktop.
Save huevos-y-bacon/64cd96a66c4c328e74da3888d2b703ca to your computer and use it in GitHub Desktop.
Simple script to convert tab separated files to CSV, e.g. DNS Zone files
#!/usr/bin/env bash
# Simple script to convert tab separated files to CSV
# E.g. DNS Zone files
if [ "$1" != "" ]; then
# File name might contain spaces
IFS=$'\n'
ZONE_FILES=("$1")
else ZONE_FILES=(
acme.co.uk.zonefile
example.com.zonefile
)
fi
for INPUT in "${ZONE_FILES[@]}"; do
echo "Processing: $INPUT"
grep -E '\t' "$INPUT" | sed 's/\t/,/g' > "$INPUT.csv"
echo " Output: $INPUT.csv"
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment