How can I get the results from grep to print on their own line in a bash script?
When using grep in the terminal, the output appears how I wish it would appear.
For instance:
$ whois x.x.85.72 | grep 'OrgName\|NetRange\|inetnum\|IPv4'
NetRange: x.x.85.64 - x.x.85.95
NetRange: x.x.0.0 - x.x.255.255
OrgName: xxxxx Technologies Inc.
When using the same grep command in bash it prints out on one line.
The output of my bash script:
$ lookup xx.com
xx.com resolves to: x.x.85.72
NetRange: x.x.85.64 - x.x.85.95 NetRange: x.x.0.0 - x.x.255.255 OrgName:xxxxx Technologies Inc.
My bash script:
#! /bin/bash
VAR1="$1"
IP=`net lookup $VAR1`
echo $VAR1 resolves to: $IP
RANGE=`whois $IP | grep 'OrgName\|NetRange\|inetnum\|IPv4'`
echo $RANGE
aside from a solution, can anyone tell me why it does this?
Thanks a bunch!