# function_1 extract lines with word Mark from file.
function_1() {
file=$1
grep "Mark" ${file}
}
Suppose output of funtion_1:
- Question 1: Mark :5:
- Question 2: Mark :1:
- Question 3: Mark :3:
Suppose function_2 needs to extract integer from function_1 output to calculate total mark.
How to give output of function_1 to funtion_2?
Advertisement
Answer
Try this code:
FILE_NAME=marks.txt
function_1() {
echo $(grep "Mark" $1)
}
function_2() {
var="$@"
echo $var
#TODO: extract integers
}
ret=$(function_1 $FILE_NAME)
function_2 ${ret}