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

2
  • sh does not have arrays Commented Apr 21, 2020 at 12:47
  • is there any way I can solve above issue? Commented Apr 21, 2020 at 13:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.