-1

I need to write a shell script which tells us all function names in a given file and their inputs/outputs

For Example consider the below file which has 2 functions. Each function has their input and output using getvalue and putvalue respectively.

static int function1()

{    
getvalue(session,"inp1",extra);    
getvalue(session,"inp2",extra);

------other code----------

putValue(session,"output1",extra);    
putValue(session,"output2",extra);

}

static int function2()   
{
getvalue(session,"inp3",extra);    
getvalue(session,"inp4",extra);

------other code----------

putValue(session,"output3",extra);   
putValue(session,"output4",extra);   
}

How do I write a script such that I can search the function name using "Static int" keyword and input/output of the function searching for "getvalue" and "putvalue" keyword within a function.

Output should be in below format.

Function Name :Function1
Input of Function :   
inp1    
inp2
Output Of Function:    
output1    
output2


Function Name :Function2
Input Of Function:    
inp3    
inp4

Output Of Function:    
output3  
output4
  • Welcome to stackexchange! I'm not exactly sure what you're trying to accomplish; non-working snippets of pseudocode with calls to undefined functions don't exactly make it clear.... Could you please edit your question and explain in plain English what it is you're trying to accomplish? – Wildcard Oct 16 '15 at 12:33
  • Re-phrased the question. – Shivaji Dubey Oct 19 '15 at 8:26
  • It took me a full minute to understand. Now I get it. The "input" is the entire first code block, and the "output" is the entire second code block. The inclusion of "input" and "output" in the text of each of them is pure misdirection. – Wildcard Oct 19 '15 at 8:34
  • Yes. :)@Wildcard – Shivaji Dubey Oct 19 '15 at 8:55
  • @Wildcard Any idea on how to get this output?? – Shivaji Dubey Oct 19 '15 at 9:04
0

Your question was not 100% clear to me. But if you're asking how to replace inp by output you can do it using awk:

print "inp1" | awk 'sub(/inp/,"output")'
  • No i don't want to replace input with output. I have edited the question. PLease check again – Shivaji Dubey Oct 19 '15 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.