0

How to store the output generated by a curl request into variables

m=$(curl  -b cookiez.txt -L http://bmcassistant.org/webac/Department/Student/CurrentSemesterDetails.aspx?|grep -o 'href=.*>.*%' | grep -o '>.*%'|sed 's/>//') 

echo $m>>attendance.txt

Output of attendance.txt

10% 80% 50% 100%

I want to store these numbers into variables like m,n,o,p So i can call it later in shell script by referencing them by $m,$n,$o,$p

1 Answer 1

1

I think this should do the trick:

while IFS='' read -r line || [[ -n "$line" ]]; do
  read -a arr <<< $line
  echo ${arr[@]}
done < "attendance.txt"

Change the @ for the different values.

Instead of reading the txt file again, as you have $m which has the string, you can simply do this:

read -a arr <<< $m
Sign up to request clarification or add additional context in comments.

1 Comment

@JohnsSimon If it solved your problem, kindly accept the answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.