0

I'm unable to detect the cause of error.

Please help point me out and it's corrective action. I'm a beginner and so this will be a great help to me.

mapping.txt:

test1 hello
test2 world

My Sh file: parameter 1 = hello

a= cat mapping.txt | grep $1 | awk '{print$1}'
echo $a

## Extracting Dump name
b=$(ls -ltr  /home/oracle/$a/$1*.dmp | awk '{print $9}' | tail -1)

I'm getting test1 as echo, but i'm unable to substitute in /home/oracle/$a/$1*.dmp script

output: ls: /home/oracle//hello*.dmp: No such file or directory

What change should i do to let it substitute as: /home/oracle/test1/hello*.dmp

4

1 回答 1

4

From the error, you can see the variable a is not set:

Change your first line from:

a= cat mapping.txt | grep $1 | awk '{print$1}'

to:

a=$(cat mapping.txt | grep $1 | awk '{print$1}')
于 2012-10-02T21:57:34.547 回答