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 ?
在将适当的字段分隔符IFS
设置为之后,更改您的read
语句:
while IFS=":" read -r dbname table; do
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.