Created
July 2, 2018 15:46
-
-
Save rtanikella/bb2492bb36f3b7cabe314c938601e059 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/bash | |
if [ ! -n "$1" ] | |
then | |
help_text=$( cat <<ENDxxx | |
Use this to adjust the URLs of links within Classic Salesforce Knowledge | |
Articles to reference the destination Salesforce instance instead of the | |
source instance. | |
Usage: $0 input-file.csv prefix | |
where | |
input-file.csv is an extract of Classic Knowledge Articles from | |
Salesforce in the form of "Id","Article_content" | |
prefix is a string to prepend to the final output file name. | |
If none is provided then this will be 'Replaced_' | |
Script will | |
remove all line breaks (collapsing into a single line, outputting | |
intermediate temp file chomped.csv) | |
introduce line breaks ahead of head article Id (making the CSV one article | |
per line, outputting intermediate temp file one-per-line.csv) | |
replace all instances of /Knowledge_Article_Type/ with /Article/, writing | |
the final output to a new file entitled as Replaced-input-file.csv (the | |
input file name prefixed with 'Replaced-', or with the prefix text if | |
provided.) | |
ENDxxx | |
) | |
echo "$help_text" | |
exit | |
fi | |
if [ ! -n "$2" ] | |
then | |
OUTNAME="na33-to-clarivateanalytics_$1" | |
else | |
OUTNAME="$2$1" | |
fi | |
perl -pe "chomp;" "$1" > chomped.csv | |
perl -pe 's/"ka1/\n"ka1/sg;' chomped.csv > one-per-line.csv | |
perl -ne 'if($_ =~ s/\/na33.salesforce.com\//\/clarivateanalytics.my.salesforce.com\//g){print;}' one-per-line.csv > "$OUTNAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment