I have got a file job_tree.lst , which contains 1 line as below
$ cat job_tree.lst
ABC_D_EQ_XXXXX_YYYY_PRD_UX 05/08/2009 05:47 05/08/2009 05:50 IN 13412850/0
I want to get a child job string 3 characters offset from the parent job string (i.e. ABC_D_EQ_XXXXX_YYYY_PRD_UX 05/08/2009 05:47 05/08/2009 05:50 IN 13412850/0 available in job_tree.lst)
The command I am using in shell script to carry out the above task is as below
grep $parent job_tree.lst | tail -1 |sed -e 's*'${parent_job_rep}''' '${child_job_rep}''
but it's producing an error �SED command: Command Garbled error�
Pl see the test below what I have done in the command prompt
$ cat job_tree.lst
ABC_D_EQ_XXXXX_YYYY_PRD_UX 05/08/2009 05:47 05/08/2009 05:50 IN 13412850/0
$ echo $parent
ABC_D_EQ_XXXXX_YYYY_PRD_UX
$ echo $child_job_rep
XYZ_D_EQ_XXXXX_YYYY_PRD_UX 05/08/2009 05:47 05/08/2009 05:50 IN 13412850/0
$ echo $parent_job_rep
ABC_D_EQ_XXXXX_YYYY_PRD_UX 05/08/2009 05:47 05/08/2009 05:50 IN 13412850/0
$ grep $parent job_tree.lst | tail -1 |sed -e 's*'${parent_job_rep}''' '${child_job_rep}''
sed: command garbled: s*ABC_D_EQ_XXXXX_YYYY_PRD_UX
But when I give literals in place of substitution variables , it's working see below
$ grep $parent job_tree.lst | tail -1 |sed -e 'sABC_D_EQ_XXXXX_YYYY_PRD_UX 05/08/2009 05:47 05/08/2009 05:50 IN 13412850/0 XYZ_D_EQ_XXXXX_YYYY_PRD_UX 05/08/2009 05:47 05/08/2009 05:50 IN 13412850/0*'
XYZ_D_EQ_XXXXX_YYYY_PRD_UX 05/08/2009 05:47 05/08/2009 05:50 IN 13412850/0
Can the experts help?
Thanks