how to search a string in a variable and get part of the variable in bash

HI Friends,

1. below is the sample input.txt, which I loop thru line by line using while / do loop
2. how to search a string in each line and get part of the variable and concat it

Would like to search for "asset", "description", "arg1", "arg2", "arg3", "arg4", "arg5" and get the value, then concat with name/value pair

e.g final output what I would like to have in a variable
var='asset="task1"&description="description of task1"&arg1="some arg1"&arg2="some arg2"&arg3="some arg3"&arg4="some arg4"&arg5="some arg5"'


input.txt
job_1_name=job1
job_1_asset="task1"
job_1_dependent_on="none"
job_1_status="not started"
job_1_description="description of task1"
job_1_arg1="some arg1"
job_1_arg2="some arg2
job_1_arg3="some arg3"
job_1_arg4=none
job_1_arg5=none


Pls help and thx in advance.
enthuguyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
#!/usr/bash
while read line ; do eval ${line%=*}="'"${line#*=}"'" ; done < input.txt
var="asset=$job_1_asset&description=$job_1_description&arg1=$job_1_arg1&arg2=$job_1_arg2&arg3=$arg3=&arg4=$job_1_arg4&arg5=$job_1_arg5"
echo $var
enthuguyAuthor Commented:
Thanks Ozo, your soluction works fine. but more advance for me :)

It is possible to have $job_1_xxxxx to be generic please. reason next input file will have

job_2_name=job2
job_2_asset="task2"
job_2_dependent_on="none"
job_2_status="not started"
job_2_description="description of task2"
job_2_arg1="some arg1"
job_2_arg2="some arg2
job_2_arg3="some arg3"
job_2_arg4=none
job_2_arg5=none
ozoCommented:
#!/usr/bash
ifs=$IFS
IFS='='
while read a b ; do eval ${a##*_}\=\'${b}\' ; done < input.txt
IFS=$ifs
var="asset=$asset&description=$description&arg1=$arg1&arg2=$arg2&arg3=$arg3&arg4=$arg4&arg5=$arg5"
echo $var

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
enthuguyAuthor Commented:
Thanks very much!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.