I am facing issues with the below:
I have a lookup file say lookup.lkp.This lookup.lkp file contains strings delimited by comma(,).
Now i want to read this command from file and execute it.
So my code below is :
Contents in the lookup.lkp file is :
c_e,m,a,`cd $BOX | ls cef_*|tail -1`,/home/me
In my shell script I read it as :
$(cat lookup.lkp | grep c_e | cut -d ',' -f4)
So above command should pick up
`cd $BOX | ls cef_*|tail -1`
which it does....but the command does not return the file name starting with cef_some_name even though there are files which match the wildcard.
Instead it quits using no such file or directory.
Two things to change in your lookup file:
a) don't pipe the cd $BOX to the next statement as it doen't make sense - cd has no output and ls doesn't read stdin.
b) strip the backticks off that entire command list; they make it try to execute the result of the ls, which is some cef_* file which is not executable.
You lost me - sorry. What's the result of cat $file_path | grep -i $STR | cut -d '*' -f4 ?
Why don't you execute the relevant part of your code with the xtrace option on and post the result?