Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to use sed with awk 1

Status
Not open for further replies.

liondari

Technical User
Oct 4, 2004
7
GR
Hello everybody!
I have two files (sd.data and sdisk.cpp).
I would like to extract some information out of sd.data.
For example the product of the two numbers after the word initUcell:

initUcell 10 10
stepLimit 20000
..
..

Then I would like to substitute the result (in this case 100) into some regexp which occurs in file sdisk.cpp.

How can I use awk, sed or a combination within a script to achieve this?
Thank you for your help!
Kind regards!
 
Something like this ?
Ucell=`awk '/^initUcell /{printf "%d",$2*$3}' sd.data`
sed "s!some regexp!${Ucell}!g" sdisk.cpp > newsdisk.cpp

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top