how to get the specified content of the text into a variable.

I am having one string like

./usr1/Server/temp/app.env ./usr1/Server/temp/upp/app.env ./usr1/Server/ORIG_temp/app.env ./usr1/Server/ORIG_temp/upp/app.env ./usr1/Server/work_temp_40/app.env ./usr1/Server/work_temp_40/upp/app.env ./usr1/fd/app.env ./usr1/PurgeArchive/app.env ./usr1/bm/bin/app.env ./usr1/apps/bin/app.env ./usr1/apps/ORIG_bin/app.env

from the above string i need the content that ends with temp/app.env
that means i have to take ./usr1/Server/temp/app.env it into a varible.

the content "./usr1/Server/"may variey from one server to the other so my code is to be generic.

You could do this

var=$(tr ' ' "\n" < $file| grep "\/temp\/app.env")

where $file contains the string.

Thanks for your replay.After using the above cmd i am getting the following error
Error

No such file or directory
Test1.sh[21]: ./usr1/Server/temp/app.env ./usr1/Server/temp/upp/app.env ./usr1/Server/ORIG_temp/app.env ./usr1/Server/ORIG_temp/upp/app.env ./usr1/Server/work_temp_40/app.env ./usr1/Server/work_temp_40/upp/app.env ./usr1/fd/app.env ./usr1/PurgeArchive/app.env ./usr1/bm/bin/app.env ./usr1/apps/bin/app.env ./usr1/apps/ORIG_bin/app.env: cannot open

For your reference i am pasting the code

Code

find_name=$(find . -name "app.env");
var=$(tr ' ' "\n" < $find_name| grep "\/temp\/app.env")

Please post the entire script.

#!/bin/sh

find_name=$(find . -name "app.env");
var=$(tr ' ' "\n" < $find_name| grep "\/temp\/app.env")

'Here in the below command i have hardcoded the path(/usr1/Server/temp/app.env).
Instead i am looking to keep the O/P of var in the below commad

grep "login_name" /usr1/Server/temp/app.env | cut -d = -f1

Use

find_name=$(find . -name "app.env");
var=$(echo "${find_name}" | tr ' ' "\n" | grep "\/temp\/app.env")

Not tested though. But I think it should work.

Thanks for the response.Its your code is working.