Q:

Store multiple grep in one command output to a variable

I am trying to get a list of IPs that are UP, so used nmap to first save all of them in a text file:
nmap -v -sn 10.10.10.1-254 -oG hosts.txt 

Now I want to run another nmap command on these IPs, so to parse and get the IP from the text file.   I am trying the following, but its not working; the variable v does not have the value of IP saved:
#! /bin/bash
while read line; do    
    v=$line|grep 'Up' -B1|grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'

    echo $v
done < hosts.txt

A:

Your script doesn't appear to be properly written:
v=$line | grep [...]

Assigning a variable has no output, so you are piping nothing into grep. 
It would probably be simpler to point awk at your hosts.txt file:
$ nmap -v -sn 10.10.10.1/24 -oG hosts.txt > /dev/null 2>&1
$ awk '$NF=="Up" { print $2 }' hosts.txt    

Given the format of the file created by nmap (forgive the different IP range; I'm clearly on a different network but the example is still valid):
$ head hosts.txt
# Nmap 7.60 scan initiated Fri May 11 10:14:28 2018 as: nmap -v -sn -oG hosts.txt 172.28.9.67/24
# Ports scanned: TCP(0;) UDP(0;) SCTP(0;) PROTOCOLS(0;)
Host: 172.28.9.0 (hostname1.internal)   Status: Up
Host: 172.28.9.1 (hostname2.internal)   Status: Up

If we're only interested in hosts which show Status: Up, helpfully the magic word is the last one on the line.   So we use awk to look only at those lines where the last field is equal to Up, and print the second field (to wit: the IP address).