-1

This is my .sh File

#!/bin/bash

/opt/cassandra/bin/./cqlsh -e "COPY mykeyspace.sampletable(id ,name ,employee,address) TO '/opt/AllCsv/$csvName.csv' WITH HEADER = true AND delimiter = '|' ;"

I am trying to execute it by

./copy.sh companyname

This is not placing the argument value at "$csvName" position. What went wrong ?

ritzy
  • 45
  • 4

1 Answers1

1

The first argument to a script is "$1". If you want to use a variable $csvName then you have to assign it:

#!/bin/bash

csvName="$1"
/opt/cassandra/bin/./cqlsh -e "COPY mykeyspace.sampletable(id ,name ,employee,address) TO '/opt/AllCsv/$csvName.csv' WITH HEADER = true AND delimiter = '|' ;"
John Kugelman
  • 349,597
  • 67
  • 533
  • 578