Im very new shell script. Im ran the below sqoop command in shell script and got the result.
sqoop command in shell script
#!/bin/bash
while read table; do
sqoop eval --connect jdbc:mysql://127.0.0.1/mydb --username root --password cloudera --query "describe $table"
done<tables.txt
Input file: tables.txt has just one word: MYTAB And Im gettting result for that.
But how can I write a script to take two parameters from the file when data in tables.txt looks like this: MYDB:MYTAB and I want to pass dbname and table name to my sqoop command in the script which looks like below.
#!/bin/bash
while read table; do
sqoop eval --connect jdbc:mysql://127.0.0.1/$dbname --username root --password cloudera --query "describe $table"
done<tables.txt
Can anyone tell me how to extract the values from the file and put them in the file ?
Change your read
statement after setting the proper field separator IFS
to :
while IFS=":" read -r dbname table; do