This script transforms a headerless CSV file (containing URL Codes and URLs) into a number of plaintext files named after the URL Code and containining the (actual) URL.
Created
October 25, 2019 15:04
-
-
Save operatehappy-bot/d13dd09648701c1085a69f628a19f27c to your computer and use it in GitHub Desktop.
Create URL files from CSV
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/sh | |
URLS_FILE="urls.csv" | |
URLS_DIR="urls" | |
mkdir -p "${URLS_DIR}" | |
while IFS=, read -r CODE URL | |
do | |
if [ -z "${CODE}" ]; | |
then | |
echo "missing code for item with URL \"${URL}\"}"; | |
else | |
echo "creating file ${URLS_DIR}/${CODE} for ${URL}"; | |
echo "${URL}" > "${URLS_DIR}/${CODE}" | |
fi | |
done < "${URLS_FILE}" |
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
2BkX2OA | https://example.com/ | |
---|---|---|
1xA5Lab | https://example.net/ | |
Z6lawAb | https://example.org/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment