I have a file with more than 20-30 functions like below:
abc(){
# code of abc function
}
efg(){
# code of efg function
}
hij(){
# code of efg function
}
I want to use grep
/sed
or any other text manipulation tools to extract the code present in a particular function.
I tried this:
sed -n '/efg/,/\}/p' file.txt
Output:
efg(){
# code of efg function
}
How do I exclude the first and last line of the output to get the code only. I know it can be removed using sed but I'd prefer it is in the one-liner itself, but can't figure it out myself