0

I have a script which accepts 3 arguments $1 $2 $3

but $3 is an array like ("2018" "01")

so I am executing my script as :

sh script.sh Employee IT "2018 01"

and there an HQL file ( emp.hql) in which I want to replace my partition columns with the array passed like below :

***"select deptid , employee_name from {TBL_NM} where year={par_col[i]} and month={par_col[i]}"***

so below is the code I have tried :

**Table=$1
dept=$2
Par_cols=($3)
 for i in "${par_cols[@]}" ;do
sed -i "/${par_col[i]}/${par_col[i]}/g" /home/hk/emp.hql**
done

Error :

*sed: -e experssion #1 , char 0: no previous regular expression*


*sed: -e experssion #2 , char 0: no previous regular expression*

But I think logic to replace partition columns is wrong , could you please help me in this?

Desired Output in HQL file :

select deptid ,employee_name from employee where year=2018 and month=01

Little bit related to below like :

Shell script to find, search and replace array of strings in a file

harsh
  • 17
  • 9

0 Answers0