Ich schreibe ein Skript, um eine Spalte Daten in eine andere Spalte zu kopieren. Versuchte mit folgenden nur knapp sein Ziel Logik Knospe arbeitete out- o/p- Anzahl der Parameter ist 0.Skript zum Kopieren von Daten einer Spalte in eine andere Spalte
Mein Logik- • ich die Schlüssel aus dem admintable bekam und dann die Daten zu einem gewissen updateupdateStatement Datei kopiert. • Mit dem Befehl awk kopierte ich bestimmte Spaltendaten in eine temporäre Datei • Bereitete dann eine update-Anweisung vor und führte sie dann aus.
#!/bin/ksh
#
# Script to Populate cross_refs based on what is in cross_references
#
#
echo "number of parameters is $#"
if [ $# != 1 ]; then
USAGE="USAGE: $0 cassPassword"
echo ${USAGE}
exit 1
fi
cassPassword=$1
#Add column to admin table
#echo "alter table to add column..."
#echo "ALTER TABLE admin.product ADD cross_refs Map<String,String>;" > updateTable.cql
#cqlsh -u dgadmin -p ${cassPassword} -f updateTable.cql
echo "get keys from cassandra"
echo "copy admin.product (cross_references) to 'updateupdateProductStatement.cql';" > copyInputs.cql
cqlsh -u dgadmin -p ${cassPassword} -f copyInputs.cql
#Convert file that Cassandra created from DOS to Unix
echo "DOS to Unix conversion..."
tr -d '\015' <updateupdateProductStatement.cql >updateupdateProductStatement2.cql
cat updateupdateProductStatement2.cql >tempFile
sed -i "s/^/update admin.product set cross_refs = '/" tempFile
#execute the updated .cql file to run all the update statements
echo "executing updateupdateProductStatement.cql..."
cqlsh -u dgadmin -p ${cassPassword} -f tempFile
Ihre Tags sagen bash, aber Ihr Skript ist ksh. Überlegen Sie, ob Sie ein ksh-Tag hinzufügen und das Bash-Tag entfernen, damit Ihre Frage die Zielgruppe erreicht. –