Created
January 18, 2024 10:45
-
-
Save huevos-y-bacon/64cd96a66c4c328e74da3888d2b703ca to your computer and use it in GitHub Desktop.
Bash - Simple script to convert tab separated files to CSV, e.g. DNS Zone files
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
#!/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